【发布时间】:2011-04-12 14:57:01
【问题描述】:
我有一个小 xml 动画,可以为我的布局中的几个 ImageView 设置动画。实际上它是来自 api demos sdk 示例的波形动画。该动画将图像放大然后缩小到其原始大小,因此它看起来有点像波浪。问题是当图像被放大时,它看起来很糟糕,边缘有锯齿并且图像是块状的。 我的动画是这样的:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="100" />
<scale
android:fromXScale="0.5" android:toXScale="1.25"
android:fromYScale="0.5" android:toYScale="1.25"
android:pivotX="50%" android:pivotY="50%"
android:duration="200" />
<scale
android:fromXScale="1.25" android:toXScale="1.0"
android:fromYScale="1.25" android:toYScale="1.0"
android:pivotX="50%" android:pivotY="50%"
android:startOffset="200"
android:duration="100" />
</set>
我尝试了,而不是直接在 ImageView 的 src 中加载图像,而是将其包装在 xml 位图元素中并启用抗锯齿和过滤,但没有任何区别。
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/myimage_img"
android:antialias="true"
android:filter="true"
android:tileMode="disabled"
/>
我的 ImageView 看起来像这样:
<ImageView android:src="@drawable/myimage" android:layout_height="wrap_content" android:layout_margin="5dp" android:adjustViewBounds="true" android:layout_width="fill_parent" android:scaleType="centerInside"></ImageView>
还请注意,图像并未真正放大。图像本身比它出现在屏幕上的要大。它在 ImageView 内居中。但是看起来动画不是使用原始图像以不同的大小渲染它,而是使用 ImageView 中的缩小图像并再次放大它。
你能帮我让我的图像在动画时看起来很平滑吗?
【问题讨论】:
标签: android animation filter imageview