1. <small id='CuMJz'></small><noframes id='CuMJz'>

      • <bdo id='CuMJz'></bdo><ul id='CuMJz'></ul>
    2. <legend id='CuMJz'><style id='CuMJz'><dir id='CuMJz'><q id='CuMJz'></q></dir></style></legend>

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

    3. <tfoot id='CuMJz'></tfoot>
    4. Android:将imageview中的图像旋转一个角度

      Android: Rotate image in imageview by an angle(Android:将imageview中的图像旋转一个角度)

      <small id='hXZOz'></small><noframes id='hXZOz'>

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

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

                问题描述

                限时送ChatGPT账号..

                我正在使用以下代码将 ImageView 中的图像旋转一个角度.有没有更简单和不太复杂的方法可用.

                I am using the following code to rotate a image in ImageView by an angle. Is there any simpler and less complex method available.

                ImageView iv = (ImageView)findViewById(imageviewid);
                TextView tv = (TextView)findViewById(txtViewsid);
                Matrix mat = new Matrix();
                Bitmap bMap = BitmapFactory.decodeResource(getResources(),imageid);
                mat.postRotate(Integer.parseInt(degree));===>angle to be rotated
                Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,bMap.getWidth(),bMap.getHeight(), mat, true);
                iv.setImageBitmap(bMapRotate);
                

                推荐答案

                另一种旋转ImageView的简单方法:
                更新:
                所需的进口:

                Another simple way to rotate an ImageView:
                UPDATE:
                Required imports:

                import android.graphics.Matrix;
                import android.widget.ImageView;
                

                代码:(假设 imageViewanglepivotX & pivotY 已经定义)

                Code: (Assuming imageView, angle, pivotX & pivotY are already defined)

                Matrix matrix = new Matrix();
                imageView.setScaleType(ImageView.ScaleType.MATRIX);   //required
                matrix.postRotate((float) angle, pivotX, pivotY);
                imageView.setImageMatrix(matrix);
                

                此方法不需要每次都创建新的位图.

                This method does not require creating a new bitmap each time.

                注意:要在运行时在 ontouch 上旋转 ImageView,您可以在 ImageView 上设置 onTouchListener &通过添加最后两个来旋转它上述代码中的行(即 postRotate 矩阵并在 imageView 上设置它)触摸监听器 ACTION_MOVE 部分中的部分.

                NOTE: To rotate an ImageView on ontouch at runtime you can set onTouchListener on ImageView & rotate it by adding last two lines(i.e. postRotate matrix & set it on imageView) in above code section in your touch listener ACTION_MOVE part.

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

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How To Create a Rotating Wheel Control?(如何创建转轮控件?)
                iOS 6 rotations: supportedInterfaceOrientations doesn#180;t work?(iOS 6 旋转:supportedInterfaceOrientations 不起作用?)
                CABasicAnimation rotate returns to original position(CABasicAnimation 旋转返回原始位置)
                How to avoid restarting activity when orientation changes on Android(如何在 Android 上的方向更改时避免重新启动活动)
                UITabBarController Rotation Issues in ios 6(ios 6 中的 UITabBarController 旋转问题)
                iOS: How to run a function after Device has Rotated (Swift)(iOS:设备旋转后如何运行函数(Swift))
                    <tbody id='WdHJ3'></tbody>

                    <tfoot id='WdHJ3'></tfoot>
                    • <bdo id='WdHJ3'></bdo><ul id='WdHJ3'></ul>

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

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