【问题标题】:Image bigger than screen is cropped when animated动画时会裁剪大于屏幕的图像
【发布时间】:2023-03-24 17:38:01
【问题描述】:

我需要旋转一个比屏幕大的轮子图像(这是必须的)。

问题是 android:scaleType="center" 是显示大于屏幕而不被缩放的图像所必需的,并且这个相同的标签在旋转时裁剪图像(见下面的截图)

这是我的布局代码:

<ImageView 
    android:id="@+id/wheel_img"
    android:scaleType="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/wheel_test" />

我的活动:

ImageView wheel_img = (ImageView) findViewById(R.id.wheel_img);
wheel_img.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotation));

还有 anim/rotation.xml

<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromDegrees="0"
    android:toDegrees="30"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fillAfter="true"
    android:duration="2000" />

知道如何解决这个问题吗?这其实很紧急!

提前致谢!

【问题讨论】:

    标签: android rotation scale android-imageview android-animation


    【解决方案1】:

    这是我使用的技巧

    使用框架布局

       <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
        >
    
           <ImageView
               android:id="@+id/wheel_image"
               android:layout_width="image width"
               android:layout_height="image height"
               android:src="@drawable/wheel_test"
               android:layout_gravity="center" />
    

    像魅力一样工作。

    这是我在这里的第一个贡献。希望它对你有用

    【讨论】:

      【解决方案2】:

      在滚动视图中添加你的视图就可以了

               <ScrollView
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:scrollbars="none" >
      
                  <LinearLayout
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:layout_gravity="center" >
      
                      <ImageView
                          android:id="@+id/iv_light_streak"
                          android:layout_width="500dp"
                          android:layout_height="500dp"
                          android:layout_gravity="center"                        
                          android:scaleType="centerInside"
                          android:src="@drawable/wheel_test" />
                  </LinearLayout>
              </ScrollView>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-03
        • 1970-01-01
        • 2015-11-07
        • 2020-03-04
        相关资源
        最近更新 更多