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();

Android高级UI组件(五种进度条)_第1张图片

<ProgressBar
属性列表>

ProgressBar>
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>

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

<RatingBar
属性列表>

RatingBar>
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"


        />
int progress = progresstext.getProgress();
                progress = progress+10;
                progresstext.setProgress(progress);
if (progresstext.getVisibility() ==View.GONE){
                    progresstext.setVisibility(View.VISIBLE);

                }else{
                    progresstext.setVisibility(View.GONE);
                }

(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();

Android高级UI组件(五种进度条)_第2张图片

你可能感兴趣的:(android基础知识)