ProgressBar

1. Android 当中的进度条

2. 各种进度条之间的关系

3. ProgressBar进度条的风格

4. ProgressBar的使用方法

 

1. Android 当中的进度条

   

 

2. 各种进度条之间的关系

3. ProgressBar进度条的风格

    

    

4. ProgressBar的使用方法

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:paddingBottom="@dimen/activity_vertical_margin"
 6     android:paddingLeft="@dimen/activity_horizontal_margin"
 7     android:paddingRight="@dimen/activity_horizontal_margin"
 8     android:paddingTop="@dimen/activity_vertical_margin"
 9     tools:context="first.pack.MainActivity$PlaceholderFragment" >
10 
11     <ProgressBar
12         android:id="@+id/firstProgreeBar"
13         android:layout_width="match_parent"
14         android:layout_height="wrap_content"
15         style="?android:attr/progressBarStyleHorizontal"  //设置风格的方法
16         />
17 
18 </RelativeLayout>

     

 

 

     更多设置,在xml文件中设置   

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:paddingBottom="@dimen/activity_vertical_margin"
 6     android:paddingLeft="@dimen/activity_horizontal_margin"
 7     android:paddingRight="@dimen/activity_horizontal_margin"
 8     android:paddingTop="@dimen/activity_vertical_margin"
 9     tools:context="first.pack.MainActivity$PlaceholderFragment" >
10 
11     <ProgressBar
12         android:id="@+id/firstProgreeBar"
13         android:layout_width="match_parent"
14         android:layout_height="wrap_content"
15         android:max = "200" //总量
16         android:progress="100"   //当前进度
17         android:secondaryProgress="150"  //第二进度, 类似解压缩时两个进度
18         style="?android:attr/progressBarStyleHorizontal"
19         />
20 
21 </RelativeLayout>

      

 

    

       在代码中设置进度条的方法 

 1  public static class PlaceholderFragment extends Fragment {
 2         
 3         private ProgressBar progressBar;
 4 
 5         public PlaceholderFragment() {
 6         }
 7 
 8         @Override
 9         public View onCreateView(LayoutInflater inflater, ViewGroup container,
10                 Bundle savedInstanceState) {
11             View rootView = inflater.inflate(R.layout.fragment_main, container, false);
12             
13             progressBar = (ProgressBar)rootView.findViewById(R.id.firstProgreeBar);
14             
15             progressBar.setMax(50);
16             progressBar.setProgress(10);
17             progressBar.setSecondaryProgress(40);
18             
19             return rootView;
20         }
21     }

         

 

 

      更多设置

      

 1 public static class PlaceholderFragment extends Fragment {
 2         
 3         private ProgressBar progressBar;
 4 
 5         public PlaceholderFragment() {
 6         }
 7 
 8         @Override
 9         public View onCreateView(LayoutInflater inflater, ViewGroup container,
10                 Bundle savedInstanceState) {
11             View rootView = inflater.inflate(R.layout.fragment_main, container, false);
12             
13             progressBar = (ProgressBar)rootView.findViewById(R.id.firstProgreeBar);
14             
15             progressBar.setMax(50);
16             progressBar.setProgress(10);
17             progressBar.setSecondaryProgress(40);
18             
19             progressBar.incrementProgressBy(10);  //现有基础上增加10
20             
21             Boolean flag =  progressBar.isIndeterminate();  //判断是否是确定的进度, 像圆圈转圈的就不是确定进度
22             
23             return rootView;
24         }
25     }

 

转载于:https://www.cnblogs.com/iMirror/p/3831373.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值