ProgressBar as Spinner in Android

Set the style of a ProgressBar to spinner in Android.


Libraries

Code Snippet
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="20px"
    android:id="@+id/spinnerContainer">
        <ProgressBar
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" />
</RelativeLayout>


Implementation

The RelativeLayout is optional but I prefer to use a spinner within a RelativeLayout. It's also recommend to set a height! In most cases the default size of such a spinner is too large. To disable or enable the spinner just use (take a look here for further informations: https://vsnippets.com/snippet.php?s=5810bce63eb77&t=Change%20Visibility%20of%20View%20in%20Android): <code>findViewById(R.id.spinnerContainer).setVisibility(View.VISIBLE); // Enable spinner findViewById(R.id.spinnerContainer).setVisibility(View.GONE); // Disable spinner</code>





Comments
  • mode_editWrite a comment



  • forumComments




Embed Code

We provide special containers which include the full snippet and a link to this site. So for example when you make a tutorial and you are using code from this site, you can use one of the following snippet embeddings:

Load Preview Get Code Close Preview







    Share
    Rating
    thumb_up 0 thumb_down
    Author
    Thorolus

    I'm the head developer and co-founder of GlovilGames Studios (glovilgames.com) and other platforms GlovilGames created, like vsnippets.com, worth-calculator.net, python-obfuscator.com and some mobile apps and games.

    Tags
    Android
    XML



    Informations

    posted on 2016-10-26 16:41:01

    viewed 84 times

    snippet's UUID is 5810c07d82ba3

    Similar Snippets