1. <legend id='E1BM7'><style id='E1BM7'><dir id='E1BM7'><q id='E1BM7'></q></dir></style></legend>
        <bdo id='E1BM7'></bdo><ul id='E1BM7'></ul>
      <tfoot id='E1BM7'></tfoot>

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

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

        围绕指定点旋转图像不起作用!(安卓)

        时间:2023-05-18

            <legend id='5iGog'><style id='5iGog'><dir id='5iGog'><q id='5iGog'></q></dir></style></legend>

            <small id='5iGog'></small><noframes id='5iGog'>

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

                  <bdo id='5iGog'></bdo><ul id='5iGog'></ul>
                • 本文介绍了围绕指定点旋转图像不起作用!(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用 postRotate(float degree, float px, float py) 旋转 ImageView,将 px 和 py 设置为几个不同的值,包括 (0,0) 和 (imgView.getHeight(),imgView.getWidth()) 但它拒绝围绕中心以外的任何其他点旋转.我想知道这是否与我的重心位于 LinearLayout 中这一事实有关?

                  I'm rotating an ImageView with postRotate(float degrees, float px, float py), setting px and py to a few differnt values including (0,0) and (imgView.getHeight(),imgView.getWidth()) but it refuses to rotate around any other point than the center. I'm wondering whether it's got anything to do with the fact that my gravity is center in the LinearLayout?

                  我的布局:

                  <LinearLayout
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="vertical"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:gravity="center">
                  
                      <ImageView
                          android:id="@+id/imageTraj"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:scaleType="matrix"
                          android:src="@drawable/impactangle" />
                  

                  我如何旋转图像:

                  matrix.postRotate(degrees,imageView.getHeight(),imageView.getWidth());
                  imageView.setImageBitmap(Bitmap.createBitmap(imageScaled, 0, 0,
                                  imageScaled.getWidth(), imageScaled.getHeight(), matrix, true));
                  

                  PS 我注意到有一些类似的问题,但都没有合适的答案.

                  PS I've noticed there are a few similar questions, but none of them have suitable answers.

                  推荐答案

                  我正在使用自定义 ImageView 来设置角度旋转.

                  I am using a custom ImageView where I set the angle rotation.

                  public class CompassImage extends ImageView {
                      private float angleRotation;
                  
                      public CompassImage(Context context) {
                          super(context);
                      }
                  
                      public CompassImage(Context context, AttributeSet attrs) {
                          super(context, attrs);
                      }
                  
                      public CompassImage(Context context, AttributeSet attrs, int defStyle) {
                          super(context, attrs, defStyle);
                      }
                  
                      public void setAngleRotation(float angleRotation) {
                          this.angleRotation = angleRotation;
                          invalidate();
                      }
                  
                      @Override
                      protected void onDraw(Canvas canvas) {
                          Rect clipBounds = canvas.getClipBounds();
                          canvas.save();
                          canvas.rotate(angleRotation, clipBounds.exactCenterX(), clipBounds.exactCenterY());
                          super.onDraw(canvas);
                          canvas.restore();
                      }
                  }
                  

                  如果您使用 clipBounds,您可能会发现这很有帮助.

                  If you play around with clipBounds you may find that helpful.

                  这篇关于围绕指定点旋转图像不起作用!(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Android:屏幕旋转、销毁和服务难题 下一篇:3d 中的 Android ViewGroup 旋转

                  相关文章

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

                  <small id='77RJk'></small><noframes id='77RJk'>

                • <tfoot id='77RJk'></tfoot>

                  <legend id='77RJk'><style id='77RJk'><dir id='77RJk'><q id='77RJk'></q></dir></style></legend>

                        <bdo id='77RJk'></bdo><ul id='77RJk'></ul>