Android Learning-ultra-simple implementation with progress ProgressBar scroll bar

Source: Internet
Author: User

Idea: Want to show percentage progress on ProgressBar, Baidu, Google search, full screen is that textprogressbar, I did not cite that, at that time feel should be easier to achieve, so directly on the UI to try, Put ProgressBar in the Relativelayout layout, and add a textview behind the ProgressBar, so that the two control overlay is resolved, the following is the XML, you can refer to ~

650) this.width=650; "title=" QQ picture 20150316150605.png "alt=" wkiol1ugghyrzq2zaabw3ffcjpa002.jpg "src="/http S3.51cto.com/wyfs02/m01/5b/52/wkiol1ugghyrzq2zaabw3ffcjpa002.jpg "/>

Xml:

<?xml version= "1.0"  encoding= "Utf-8"? ><linearlayout xmlns:android= "http// Schemas.android.com/apk/res/android "    android:layout_width=" Match_parent "     android:layout_height= "match_parent"     android:orientation= "Horizontal"       android:layout_gravity= "center"     android:background= "#FFFFFF" >            <TextView         android:id= "@+id/tvgraphtype"          Android:layout_width= "84DP"         android:layout_height= "wrap_content "        android:padding=" 2SP "         android:gravity= "Right"         android:maxlength= "6"         &nbSp;android:textcolor= "#666666"                     android:text= "Type"         android : textsize= "13SP"/>    <relativelayout                 android:layout_width= "Fill_parent"          android:layout_height= "Fill_parent"          android:orientation= "Vertical" >        <ProgressBar              android:id= "@+id/pbGraph"               style= "? android:attr/ Progressbarstylehorizontal "              Android:layout_width= "Match_parent"              android:layout_height= "Wrap_content"               android:gravity= "Right"               android:padding= "2SP"               android:progressdrawable= "@drawable/pbarcolor_out"                android:layout_marginleft= "4DP"              android:layout_marginright= "4DP"               android:layout_ Marginbottom= "4DP"/>        <textview              android:id= "@+id/tvgraphpercent"               android:layout_width= "Match_parent"               android:layout_height= "Wrap_content"               android:gravity= "Center"               android:textcolor= "#666666"                          android:text= "%"              android:textsize= "13sp"/>     </RelativeLayout>                 </LinearLayout>

The calculation of the percentage progress on the progress bar is also posted:

Pbouts is progressbar,outpercent is used to display percentages of TextView Holder.pbOuts.setMax (Graph.getround (maxout));   Holder.pbOuts.setProgress (Graph.getround (Outcomes));   if (maxout>0) {Holder.outPercent.setText (String.valueof (Graph.getround ((outcomes*100/maxout))) + "%");   }else {holder.outPercent.setText ("0%"); } holder.outPercent.bringToFront ();//The top is displayed when the control is superimposed, which is important

This article is from the "Qytag (upspringing)" blog, so be sure to keep this source http://qytag.blog.51cto.com/6125308/1621117

Android Learning-ultra-simple implementation with progress ProgressBar scroll bar

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.