圆环进度条(默认)和水平进度条:

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<!-- 圆环形进度条-->
<ProgressBar
android:id="@+id/pbCircle"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!-- 水平进度条-->
<ProgressBar
android:id="@+id/pbHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"/> <Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="点我" /> </LinearLayout>

设置和获取水平进度条进度:

package com.example.jiandanduihuakuang;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast; public class MainActivity extends AppCompatActivity {
private ProgressBar pbHorizontal;
private Button button; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//初始化控件
pbHorizontal = findViewById(R.id.pbCircle);
button = findViewById(R.id.button);
//按钮监听器
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//setProgress()设置进度条进度,getProgress获取进度条进度
pbHorizontal.setProgress(pbHorizontal.getProgress()+10);
}
});
} }

最新文章

  1. codevs1048 石子合并
  2. js 判断浏览器和ie版本号 收集
  3. web项目知识整理
  4. IE8下ajax请求失败的解决方案
  5. Linux字符串截取和处理命令 cut、printf、awk、sed、sort、wc
  6. ActiveMQ 安装异常
  7. 使用MediaPlayer和SurfaceView播放视频
  8. javascript 实现分享功能
  9. 从C#到TypeScript - 接口
  10. pylint python2.7 安装记录
  11. vue三大框架
  12. cf441 f组合数。。单调指针
  13. bzoj2870
  14. byte数组转float 以及byte转其他类型时为什么要&amp;0xff
  15. 自动读取虚拟币ETC行情并语音提醒的小工具(mac OSX)
  16. 前端--javaScript之简单介绍
  17. 强大到无与伦比的Graphviz
  18. 开发微信小程序入门教程,含破解工具
  19. Artistic Style 3.1
  20. 厦门Uber优步司机奖励政策(12月14日到12月20日)

热门文章

  1. [学习总结]8、android 自定义控件 使用declare-styleable进行配置属性(源码角度)
  2. excel数据导入mySql数据库
  3. Nginx+ uWSGI +django进行部署
  4. 通过jquery实现form表单提交后不跳转页面,保留当前页面
  5. Java中方法和类的深入分析
  6. Linux 内核到底长啥样
  7. Sentry 开发者贡献指南 - 前端(ReactJS生态)
  8. HTML5 head标签meta标签、title的功能
  9. 深入理解css中position属性及z-index属性 https://www.cnblogs.com/zhuzhenwei918/p/6112034.html
  10. Vue页面内公共的多类型附件图片上传区域并适用折叠面板