我正在尝试为ImageView设置动画,以便从左到右慢慢显示.当我在解释我想要的东西之前问这个问题时,所以这次我使用HTML/JS创建了所需的效果:
在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"
/>
Run Code Online (Sandbox Code Playgroud)
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);
Run Code Online (Sandbox Code Playgroud)
但这个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>
Run Code Online (Sandbox Code Playgroud)
这仍然会尝试扩展我的ImageView以适应FrameLayout.