我试图给ImageView设置动画,所以它从左到右缓慢地显示。 当I asked this before我有麻烦解释一下我想要的东西,所以这一次我创建使用HTML/JS预期的效果:Animate ImageView width without scaling
什么将得到Android的这种效果的最佳方法是什么?
我试图改变scaleType,然后直接应用ScaleAnimation到ImageView的:
布局:
<ImageView
android:id="@+id/graphImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:background="@android:color/transparent"
android:contentDescription="@string/stroom_grafiek"
/>
的Java:
scale = new ScaleAnimation((float)0,
(float)1, (float)1, (float)1,
Animation.RELATIVE_TO_SELF, (float)0,
Animation.RELATIVE_TO_SELF, (float)1);
scale.setDuration(1000);
graphImage.startAnimation(scale);
但这STIL缩放图片。
我也试过在一个FrameLayout里包裹ImageView的,希望我可以动画的FrameLayout:
<FrameLayout
android:layout_width="70dp"
android:layout_height="fill_parent"
android:clipChildren="true"">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left|clip_horizontal" />
</FrameLayout>
这仍然会尝试扩大我的ImageView以适合的FrameLayout里面。
也许使用Android动画会帮助你? –