Android Custom Landscape ProgressBar

Source: Internet
Author: User

Actually very simple, on the code!

Create Drawable folder under Res, new file Drawable/progressbar_color.xml

<? xml version = "1.0" encoding = "utf-8" ?> < layer-list xmlns:android = "http://schemas.android.com/apk/res/android" >      <!-- 背景  gradient是渐变,corners定义的是圆角 -->      < item android:id = "@android:id/background" >          < shape >              < corners android:radius = "10dp" />              < solid android:color = "#ffffff" />          </ shape >      </ item >      <!-- 第二条进度条颜色 -->      < item android:id = "@android:id/secondaryProgress" >          < clip >              < shape >                  < corners android:radius = "10dip" />                  < gradient                      android:angle = "90.0"                      android:centerColor = "#ac6079"                      android:centerY = "0.45"                      android:endColor = "#6c213a"                      android:startColor = "#e71a5e" />              </ shape >          </ clip >      </ item >      <!-- 进度条 -->      < item android:id = "@android:id/progress" >          < clip >              < shape >                  < corners android:radius = "10dip" />                  < solid android:color = "#FF8080" />              </ shape >          </ clip >      </ item > </ layer-list >Then refer to it in the layout.

< ProgressBar          android:id = "@+id/my_progress"          android:layout_width = "match_parent"          android:layout_height = "12dp"          android:max = "100"          android:progress = "40"          android:secondaryProgress = "70"          style = "?android:attr/progressBarStyleHorizontal"          android:progressDrawable = "@drawable/progressbar_color" />


There is also a progress bar style loading picture:

  1. <? XML version="1.0" encoding="UTF-8" ?>                 
  2. < layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
  3. <!--Set the background color image resource --                    
  4. < Item                   
  5. Android:id = "@android: Id/background"                 
  6. android:drawable = "@drawable/prgs_bg" />
  7. <!--set the progress bar color Image Resource --                    
  8. < Item                   
  9. Android:id = "@android: Id/progress"                 
  10. android:drawable = "@drawable/prgs_progress" />
  11. </ layer-list >



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Custom Landscape ProgressBar

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.