circularprogressbar/smoothprogressbarオープンソースビュー使用学習

15868 ワード

githubアドレス:https://github.com/castorflex/SmoothProgressBar
多彩な円形進捗バーと多彩な水平進捗バー
colors.xml
変化する色の内容を定義し、gplus_でカラーで表示する
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="gplus_color_1">#3e802f</color>
    <color name="gplus_color_2">#f4b400</color>
    <color name="gplus_color_3">#427fed</color>
    <color name="gplus_color_4">#b23424</color>

    <integer-array name="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-->     
end_btn-->     

android:indeterminate="true"--> true,

app:cpb_color="#FFee44"-->
app:cpb_colors="@array/gplus_colors"-->            
app:cpb_max_sweep_angle="300"-->      ,    360,    0,    
app:cpb_min_sweep_angle="10"-->    
 app:cpb_rotation_speed="1.0"-->     ,   ,    ,   ,  

app:cpb_sweep_speed="2.0"--> ,
app:spb_colors="@array/gplus_colors"-->           
 app:spb_mirror_mode="true"-->               
app:spb_mirror_mode="false"-->             
 app:spb_sections_count="4"-->        4   
 app:spb_stroke_separator_length="4dp"->    
 app:spb_mirror_mode="true"-->true        ,false     。
app:spb_stroke_width="4dp"-->      
app:spb_reversed="false"-->false    ,true    。

  app:spb_progressiveStart_speed="5"-->カラーブロック移動開始速度
 app:spb_progressiveStop_speed="1"-->カラーブロック移動停止速度 
activty_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns: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" >

    <Button android:id="@+id/start_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" />

    <Button android:id="@+id/end_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" />

    <fr.castorflex.android.circularprogressbar.CircularProgressBar xmlns: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="300" app:cpb_min_sweep_angle="10" 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.SmoothProgressBar xmlns: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
package com.example.smoothprogressbar; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import fr.castorflex.android.circularprogressbar.CircularProgressDrawable; public class MainActivity extends Activity { private Button start_btn; private Button end_btn; //     
    private fr.castorflex.android.circularprogressbar.CircularProgressBar circularProgressBar; //     
    private fr.castorflex.android.smoothprogressbar.SmoothProgressBar smoothProgressBar; @Override protected void onCreate(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(new OnClickListener() { @Override public void onClick(View arg0) { //       
                CircularProgressDrawable drawable = (CircularProgressDrawable) circularProgressBar .getIndeterminateDrawable(); drawable.start(); //       
 smoothProgressBar.progressiveStart(); } }); end_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //         
                CircularProgressDrawable drawable = (CircularProgressDrawable) circularProgressBar .getIndeterminateDrawable(); drawable.progressiveStop(); //         
 smoothProgressBar.progressiveStop(); } }); } }

マイプログラムgithubアドレス: