Rotate ImageView updates in ProgressBar

I am creating a custom name for my Android app and want the refresh button to appear as a Twitter app. I use RelativeLayout, and my ImageView is defined:

<ImageView android:id="@+id/title_refresh"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_menu_refresh"
    android:layout_alignParentRight="true">
</ImageView>

In mine Activity, I have something like this:

refreshView = (ImageView) findViewById(R.id.title_refresh);
refreshView.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        /* Make the refreshView turn into a progress bar. */
        startService(new Intent(MyActivity.this, MyService.class));
    }
}

I would like ImageView to turn into a ProgressBar while I wait for my service to complete processing. How to do it right?

+3
source share
1 answer

You can add a progress bar view to RelativeLayout, which overlaps ImageViewwith visibility:gone, and then plays with setVisibilty(View.VISIBILE)/ setVisibilty(View.GONE)on ImageViewand ProgressBar.

, ViewSwitcher.

+4

Source: https://habr.com/ru/post/1746268/


All Articles