android:动画可绘制对象被裁剪,边界未调整大小
我正在尝试应用比例变换来制作 PNG 动画。一切都按收缩操作的预期进行,但是当我尝试增大图像时,它会被原始视图的边界裁剪掉。
如何重置边界?有人可以给我一个如何做到这一点的例子吗?
我的设置 xml 如下所示:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.2"
android:toYScale="2.2"
android:duration="1000"></scale>
</set>
main.xml 包含一个简单的 ImageView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/anim"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/image1"/>
<.RelativeLayout>
,代码类似于
img = (ImageView) findViewById(R.id.imageView);
myanim = AnimationUtils.loadAnimation(this, R.drawable.anim);
img.startAnimation(myanim);
请帮忙!
I'm trying to animate a PNG, applying a scale transformation. All works as expected for shrink operations, but when i try and grow the image it gets cropped by the bounds of the original View.
How can reset the bounds? Can someone give me an example of how to do this?
my set xml looks like:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.2"
android:toYScale="2.2"
android:duration="1000"></scale>
</set>
main.xml contains a simple ImageView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/anim"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/image1"/>
<.RelativeLayout>
and the code is along the lines of
img = (ImageView) findViewById(R.id.imageView);
myanim = AnimationUtils.loadAnimation(this, R.drawable.anim);
img.startAnimation(myanim);
Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试在 ImageView 上设置
android:adjustViewBounds="true"
。You can try setting
android:adjustViewBounds="true"
on the ImageView.