开发者

show a "loader" in an image view

开发者 https://www.devze.com 2023-03-24 22:45 出处:网络
I know of a couple ways to do this (neither of which I like) - so I\'m turning to t开发者_运维技巧he experts at SOF.

I know of a couple ways to do this (neither of which I like) - so I'm turning to t开发者_运维技巧he experts at SOF.

I want to use the ProgressBar. The catch is that I want to use this as the image/background for my ImageView. Is there a way to do this? I started trying this with drawable but I wasn't sure how to go about it exactly.


You can use a ViewSwitcher to switch between the ImageView and a ProgressBar. You can set the ProgressBar as the first child, and when you are done loading the image, you can switch to the ImageView.


Use FrameAnimation drawable as the source of the ImageView or you can rotate it use TweenAnimation.

Animation Resource


<LinearLayout
     android:orientation="horizontal"
     ... >
     <ProgressBar
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         style="@android:style/Widget.ProgressBar.Small"
         android:layout_marginRight="5dp" />
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/loading" />
 </LinearLayout>
0

精彩评论

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

关注公众号