Circularprogressbar/smoothprogressbar Open Source View use learning

Source: Internet
Author: User

GitHub Address: Https://github.com/castorflex/SmoothProgressBar

Colorful round progress bar and colorful horizontal progress bar

Colors.xml

Define the color content of the change and use gplus_colors to mark it.

<?XML version= "1.0" encoding= "Utf-8"?><Resources>    <Colorname= "Gplus_color_1">#3e802f</Color>    <Colorname= "Gplus_color_2">#f4b400</Color>    <Colorname= "Gplus_color_3">#427fed</Color>    <Colorname= "Gplus_color_4">#b23424</Color>    <Integer-arrayname= "Gplus_colors">        <Item>@color/gplus_color_1</Item>        <Item>@color/gplus_color_2</Item>        <Item>@color/gplus_color_3</Item>        <Item>@color/gplus_color_4</Item>    </Integer-array></Resources>

Activity_main.xml

Start_btn--> Progress bar Run
End_btn--> Progress bar Stop

Android:indeterminate= "true"--default is True, otherwise the control does not display

App:cpb_color= "#FFee44"--Circular progress bar default color
app:cpb_colors= "@array/gplus_colors"--defines the array of colors for the circular progress bar
App:cpb_max_sweep_angle= "--Maximum radian size, not more than 360, cannot be less than 0, otherwise error
App:cpb_min_sweep_angle= "Ten"--min. radian
App:cpb_rotation_speed= "1.0"-the speed of the circle, the higher the value, the faster, the lower the value, the slower

App:cpb_sweep_speed= "2.0"--also control speed, temporarily unknown
app:spb_colors= "@array/gplus_colors" and define the horizontal progress bar color array
App:spb_mirror_mode= "true"-the horizontal progress bar moves in the center direction from both sides
App:spb_mirror_mode= "false"-the horizontal progress bar moves from left to right
App:spb_sections_count= "4" and 4 bars on a linear progress bar
App:spb_stroke_separator_length= "4DP"-Color block spacing
App:spb_mirror_mode= "True"-->true the sides toward the middle, false from left to right.
App:spb_stroke_width= "4DP"-color block up/down thickness
App:spb_reversed= "false"-->false left to right, true right to left.

App:spb_progressivestart_speed= "5"- color block move start speed

app:spb_progressivestop_speed= "1"-color block movement stop speed  

Activty_main.xml

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:gravity= "Center"android:orientation= "vertical" >    <ButtonAndroid:id= "@+id/start_btn"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "button" />    <ButtonAndroid:id= "@+id/end_btn"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "button" />    <Fr.castorflex.android.circularprogressbar.CircularProgressBarxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Android:id= "@+id/circularprogressbar"Android:layout_width= "100DP"Android:layout_height= "100DP"android:indeterminate= "true"App:cpb_color= "#FFee44"        app:cpb_colors= "@array/gplus_colors"App:cpb_max_sweep_angle= "+"App:cpb_min_sweep_angle= "Ten"App:cpb_rotation_speed= "1.0"App:cpb_stroke_width= "4DP"App:cpb_sweep_speed= "1.0" />    <!--app:spb_color= "#FF0000" -    <Fr.castorflex.android.smoothprogressbar.SmoothProgressBarxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Android:id= "@+id/smoothprogressbar"style= "@style/smoothprogressbar"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:indeterminate= "true"app:spb_colors= "@array/gplus_colors"App:spb_mirror_mode= "true"app:spb_progressivestart_activated= "true"App:spb_progressivestart_speed= "1.5"App:spb_progressivestop_speed= "3.4"app:spb_reversed= "false"App:spb_sections_count= "4"App:spb_speed= "2.0"App:spb_stroke_separator_length= "4DP"App:spb_stroke_width= "4DP" /></LinearLayout>

Mainactivity.java

 PackageCom.example.smoothprogressbar;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.Button;Importfr.castorflex.android.circularprogressbar.CircularProgressDrawable; Public classMainactivityextendsActivity {PrivateButton start_btn; PrivateButton end_btn; //Round progress bar    PrivateFr.castorflex.android.circularprogressbar.CircularProgressBar Circularprogressbar; //Horizontal progress bar    PrivateFr.castorflex.android.smoothprogressbar.SmoothProgressBar Smoothprogressbar; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); START_BTN=(Button) Findviewbyid (R.ID.START_BTN); END_BTN=(Button) Findviewbyid (R.ID.END_BTN); Circularprogressbar=(Fr.castorflex.android.circularprogressbar.CircularProgressBar) Findviewbyid (R.id.circularprogressbar); Smoothprogressbar=(Fr.castorflex.android.smoothprogressbar.SmoothProgressBar) Findviewbyid (R.id.smoothprogressbar); Start_btn.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View arg0) {//Round progress bar rotationCircularprogressdrawable drawable =(circularprogressdrawable) Circularprogressbar. getindeterminatedrawable ();                Drawable.start (); //Horizontal progress bar StartSmoothprogressbar.progressivestart ();        }        }); End_btn.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View arg0) {//Round progress bar stops turningCircularprogressdrawable drawable =(circularprogressdrawable) Circularprogressbar. getindeterminatedrawable ();                Drawable.progressivestop (); //horizontal progress bar stops startingSmoothprogressbar.progressivestop ();    }        }); }}

My program GitHub address:

Circularprogressbar/smoothprogressbar Open Source View use learning

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.