android--horizontal ProgressBar setting and implementation

Source: Internet
Author: User

Reprint please indicate the source, thank you ~ ~

Many people ask this horizontal ProgressBar not ah, I can only say that certainly is not set to, below I paste my settings, for reference only.

<progressbar android:id=" @+  id/game_pro " android:layout_below="  @id /game_name " android:layout_width=" 100DP " android:layout_height=" 30DP " Android:layout_mar Gintop= "10DP"  style= "android:attr/ Progressbarstylehorizontal " android:background=" @ Null  " android:layout_centerhorizontal= android:progress Drawable= " @drawable /progress_bg" /> 

Ignore what ID ah, below ah something.
Width and height are set to ProgressBar the width of the height, which can be written to death, you write how big it is.
Style must be this, only set to this will be horizontal.
Background is set to null so there is no background to cover our background.
Then progressdrawable is the focus, look inside the specific code:

<layer-list xmlns:android="Http://schemas.android.com/apk/res/android" >     <item android:id="@android: Id/background">        <shape>            <corners Android:radius="2DP" />            <gradientandroid:angle="android:centercolor" = "@drawable/ Progress_back "android:centery=" 0.75 "android:endcolor=" @drawable/progress_ Back "android:startcolor=" @drawable/progress_back " />                                                                                        </shape>    </Item>    <!--<item android:id= "@android: id/secondaryprogress" > <clip> <shape> <corners android:radius= "5dip"/> <gradient Android:startcolo                         R= "#80ffd300" android:centercolor= "#80ffb600" android:centery= "0.75"             Android:endcolor= "#a0ffcb00" android:angle= "/>" </shape> </clip> </item> -    <item android:id="@android: id/progress">        <clip>            <shape>                <corners Android:radius="2dip" />                <gradientandroid:angle="android:centercolor" = "@drawable/ Progress_forecolor "android:centery=" 0.75 "android:endcolor=" @ Drawable/progress_forecolor "android:startcolor=" @drawable/progress_forecolor " />                                                                                                                 </shape>        </clip>    </Item></layer-list>

The first item we can see is android:id= "@android: Id/background", which is not progress when the background color, here is set to a gray 16 binary. Then the second item that is commented out is secondaryprogress, you know, some progress bar two color progress, that's it. The third item is progress, which is the color of the first progress bar we want to display. After this setting, there is no problem at all. Put a picture:

android--horizontal ProgressBar setting and implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.