我試圖給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動畫會幫助你? –