开发者

Android, View width change animation?

开发者 https://www.devze.com 2023-01-15 19:50 出处:网络
I\'m trying to make a timeout gauge bar animation effect: The width of a lengthy colorful bitmap image is decreasing, but not x-scaling.

I'm trying to make a timeout gauge bar animation effect:

The width of a lengthy colorful bitmap image is decreasing, but not x-scaling.

so the image looks not changing and the visible area shrinks.

I couldn't find the sole ImageView clipping or masking support in android.

And I managed to get the clipping effect by surrounding the ImageView in ViewGroup like:

<FrameLayout android:id="@+id/shrink_box" ...>
  <ImageView android:src="@drawable/still_image" ...>
</FrameLayout>

then changing the shrink_box's width will clip the portion of the still_image.

But I failed to change the width of the view smoothly. I tried to change the LayoutParam.width in applyTransformation() but got开发者_运维百科 an Exception, it seems not allowed.

How can I make an Animation that changes the width of the view. OR is there a proper method to achieve the above effect?


You are trying to reinvent the wheel here, just use a ProgressBar and set the progress drawable to your image. In your xml layout give the ProgressBar this style to make it an actual bar rather than a wheel

style="@android:style/Widget.ProgressBar.Horizontal"
0

精彩评论

暂无评论...
验证码 换一张
取 消