当前位置:   article > 正文

Android高级UI组件(五种进度条)_android 进度条ui

android 进度条ui

在android中,提供了及进度条、拖动条和星级评分等 进度条类组件
(1)ProgressBar用于显示某个耗时操作完成的百分比的组件称为进度条组件

ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
                progressDialog.setTitle("This  is a dial");
                progressDialog.setMessage("Loading...");
                progressDialog.setCancelable(false);
                progressDialog.show();
  • 1
  • 2
  • 3
  • 4
  • 5

在这里插入图片描述

<ProgressBar
属性列表>

</ProgressBar>
  • 1
  • 2
  • 3
  • 4
XML属性描述
android:max用于设置进度条的最大值
android:progress用于指定进度条已完成的进度值
android:progressDrawable用于设置进度条轨道的绘制形式

进度条组件还有两个常用方法
setProgress(int progress)方法:用于设置进度完成的百分比
incrementProgressBy(int diff)方法:用于设置进度条的进度增加或者减少,当参数为正数时候,进度增加

(2)SeekBar允许用户通过拖动滑块来改变值的组件称为拖动条组件

<SeekBar
android:layout_height="wrap_content"
android:id="@id/SeekBar"
android:layput_width="match_parent"
>
</SeekBar>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

SeekBar组件允许用户改变拖动块的外观,使用android:thumb
(3)RatingBar允许用户通过拖动来改变进度,但是使用星星图案表示进度的组件称为星级评分条

<RatingBar
属性列表>

</RatingBar>
  • 1
  • 2
  • 3
  • 4
XML属性描述
android:isIndicator用于指定该星级评分条是否允许用户改变
android:numStars用于指定进度条已完成的进度值
android:rating用于设置进度条轨道的绘制形式
android:stepSize用于设置进度条轨道的绘制形式

星级评分条还提供了3个比较常用的办法
getRating():用于获取等级,表示选中了几颗星
getStepSize():用于获取每次最少要改变多少个星级
getProgress():用于获取进度,获取到的进度值为getRating()方法返回值与getStepSize()方法返回值之商
(4)ProgressBar
在这里插入图片描述
在这里插入图片描述

<ProgressBar
        android:id="@+id/progresstext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
        android:max="100"


        />
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
int progress = progresstext.getProgress();
                progress = progress+10;
                progresstext.setProgress(progress);
  • 1
  • 2
  • 3
if (progresstext.getVisibility() ==View.GONE){
                    progresstext.setVisibility(View.VISIBLE);

                }else{
                    progresstext.setVisibility(View.GONE);
                }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

(5)AlertDialog

AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
                dialog.setTitle("This is dialog");
                dialog.setMessage("Something important");
                dialog.setCancelable(false);
                dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }

                });
                dialog.setNegativeButton("Cancle", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                dialog.show();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/474085
推荐阅读
相关标签
  

闽ICP备14008679号