<i id='dUaTT'><tr id='dUaTT'><dt id='dUaTT'><q id='dUaTT'><span id='dUaTT'><b id='dUaTT'><form id='dUaTT'><ins id='dUaTT'></ins><ul id='dUaTT'></ul><sub id='dUaTT'></sub></form><legend id='dUaTT'></legend><bdo id='dUaTT'><pre id='dUaTT'><center id='dUaTT'></center></pre></bdo></b><th id='dUaTT'></th></span></q></dt></tr></i><div id='dUaTT'><tfoot id='dUaTT'></tfoot><dl id='dUaTT'><fieldset id='dUaTT'></fieldset></dl></div>
<legend id='dUaTT'><style id='dUaTT'><dir id='dUaTT'><q id='dUaTT'></q></dir></style></legend>
    • <bdo id='dUaTT'></bdo><ul id='dUaTT'></ul>
  • <small id='dUaTT'></small><noframes id='dUaTT'>

        <tfoot id='dUaTT'></tfoot>

        Android:将ImageView中的图像旋转90度但没有延迟

        时间:2023-05-18
          <tbody id='HrTOs'></tbody>

          <i id='HrTOs'><tr id='HrTOs'><dt id='HrTOs'><q id='HrTOs'><span id='HrTOs'><b id='HrTOs'><form id='HrTOs'><ins id='HrTOs'></ins><ul id='HrTOs'></ul><sub id='HrTOs'></sub></form><legend id='HrTOs'></legend><bdo id='HrTOs'><pre id='HrTOs'><center id='HrTOs'></center></pre></bdo></b><th id='HrTOs'></th></span></q></dt></tr></i><div id='HrTOs'><tfoot id='HrTOs'></tfoot><dl id='HrTOs'><fieldset id='HrTOs'></fieldset></dl></div>
        • <tfoot id='HrTOs'></tfoot>
          • <small id='HrTOs'></small><noframes id='HrTOs'>

                <legend id='HrTOs'><style id='HrTOs'><dir id='HrTOs'><q id='HrTOs'></q></dir></style></legend>

                  <bdo id='HrTOs'></bdo><ul id='HrTOs'></ul>
                • 本文介绍了Android:将ImageView中的图像旋转90度但没有延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在开发一个游戏,用户需要点击 ImageView 中的图像来旋转它.在每个点击图像顺时针方向旋转 90 度.但是图像从旧位置旋转到新位置需要时间.这阻碍了游戏体验.我使用了以下内容:

                  I am developing a game where a user needs to tap on the image in ImageView to rotate it. On each tap image rotates by 90 degrees in clockwise direction. But image is taking time to rotate from old to new position. This is hampering the gameplay experience. I have used the following:

                  protected void onCreate(Bundle savedInstanceState)
                  {  
                  ... 
                  ...  
                      imgview = (ImageView)findViewById(R.id.imageView1);  
                      imgview.setOnClickListener(new OnClickListener() {
                           @Override 
                           public void onClick(View arg0) {
                                Matrix matrix = new Matrix();
                                matrix.postRotate(90); 
                                Bitmap myImg = getBitmapFromDrawable(imgview.getDrawable());
                                Bitmap rotated = Bitmap.createBitmap(myImg,0,0,myImg.getWidth(),myImg.getHeight(),matrix,true);
                                imgview.setImageBitmap(rotated);
                           }
                  });
                  

                  我想知道是否有任何其他旋转方式图像不会造成任何延迟.

                  I want to know is there any other way to rotate the image without creating any delay in rotation.

                  推荐答案

                  我也尝试过一次,除了使用动画找不到任何其他解决方案.我会怎么做.

                  I also tried to do it once and couldn't find any other solution but using animation. Here how I'd do.

                  private void rotate(float degree) {
                      final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
                              RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                              RotateAnimation.RELATIVE_TO_SELF, 0.5f);
                  
                      rotateAnim.setDuration(0);
                      rotateAnim.setFillAfter(true);
                      imgview.startAnimation(rotateAnim);
                  }
                  

                  这篇关于Android:将ImageView中的图像旋转90度但没有延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:强制设备旋转 +attemptRotationToDeviceOrientation 失败 下一篇:让活动在轮换时被销毁有什么好处?

                  相关文章

                • <small id='npgl0'></small><noframes id='npgl0'>

                    <i id='npgl0'><tr id='npgl0'><dt id='npgl0'><q id='npgl0'><span id='npgl0'><b id='npgl0'><form id='npgl0'><ins id='npgl0'></ins><ul id='npgl0'></ul><sub id='npgl0'></sub></form><legend id='npgl0'></legend><bdo id='npgl0'><pre id='npgl0'><center id='npgl0'></center></pre></bdo></b><th id='npgl0'></th></span></q></dt></tr></i><div id='npgl0'><tfoot id='npgl0'></tfoot><dl id='npgl0'><fieldset id='npgl0'></fieldset></dl></div>
                    <tfoot id='npgl0'></tfoot>
                  1. <legend id='npgl0'><style id='npgl0'><dir id='npgl0'><q id='npgl0'></q></dir></style></legend>
                        <bdo id='npgl0'></bdo><ul id='npgl0'></ul>