Android 进度条
2020-01-15 11:34
253 查看
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 tools:context="com.example.administrator.android.TestActivity4" 7 android:orientation="vertical"> 8 <!--进度条--> 9 <ProgressBar 10 android:layout_width="match_parent" 11 android:layout_height="wrap_content" 12 style="?android:attr/progressBarStyleHorizontal" 13 android:progress="30" 14 android:secondaryProgress="67" 15 android:max="100" 16 android:id="@+id/pb_1"/> 17 <!-- 旋转进度条--> 18 <ProgressBar 19 android:layout_width="match_parent" 20 android:layout_height="wrap_content" 21 style="?android:attr/progressBarStyleLarge" 22 android:id="@+id/pb_2" 23 android:visibility="gone"/> 24 <!-- 可拖动进度条--> 25 <SeekBar 26 android:layout_width="match_parent" 27 android:layout_height="wrap_content" 28 android:progress="0" 29 android:secondaryProgress="0" 30 android:max="80" 31 android:id="@+id/se_1"/> 32 <!--星级进度条--> 33 <RatingBar 34 android:layout_width="match_parent" 35 android:layout_height="wrap_content" 36 android:numStars="10" 37 android:rating="5.5" 38 android:isIndicator="true"/> 39 </LinearLayout>
1 package com.example.administrator.android; 2 3 import android.app.AlertDialog; 4 import android.support.v7.app.AppCompatActivity; 5 import android.os.Bundle; 6 import android.util.Log; 7 import android.view.View; 8 import android.widget.ProgressBar; 9 import android.widget.SeekBar; 10 import android.widget.Toast; 11 12 public class TestActivity4 extends AppCompatActivity { 13 SeekBar se_1; 14 ProgressBar pb_1; 15 ProgressBar pb_2; 16 @Override 17 protected void onCreate(Bundle savedInstanceState) { 18 super.onCreate(savedInstanceState); 19 setContentView(R.layout.activity_test4); 20 21 se_1 = (SeekBar)findViewById(R.id.se_1); 22 pb_1 = (ProgressBar)findViewById(R.id.pb_1); 23 pb_2 = (ProgressBar)findViewById(R.id.pb_2); 24 25 se_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 26 // 进度改变触发 27 @Override 28 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 29 //进度条1的进度值 30 pb_1.setProgress(progress); 31 //判断是否达到最大值 32 if (progress==se_1.getMax()) 33 { 34 pb_2.setVisibility(View.INVISIBLE); //不显示 但位置仍然保留 35 } 36 else 37 { 38 pb_2.setVisibility(View.VISIBLE); 39 } 40 // 只要progress变化就被触发 41 // Toast.makeText(TestActivity4.this, "当前进度 = "+progress, Toast.LENGTH_SHORT).show(); 42 } 43 // 开始拖动 44 @Override 45 public void onStartTrackingTouch(SeekBar seekBar) { 46 47 Log.e("TAG","进度条开始拖动"); 48 } 49 // 结束拖动 50 @Override 51 public void onStopTrackingTouch(SeekBar seekBar) { 52 Log.e("TAG","进度条停止拖动"); 53 } 54 }); 55 } 56 }
1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.example.administrator.android"> 4 5 <application 6 android:allowBackup="true" 7 android:icon="@mipmap/ic_launcher" 8 android:label="@string/app_name" 9 android:supportsRtl="true" 10 android:theme="@style/AppTheme"> 11 <activity android:name=".MainActivity"> 12 </activity> 13 <activity android:name=".TestActivity4"> 14 <intent-filter> 15 <action android:name="android.intent.action.MAIN" /> 16 <category android:name="android.intent.category.LAUNCHER" /> 17 </intent-filter> 18 </activity> 19 </application> 20 21 </manifest>
转载于:https://www.cnblogs.com/TENOKAWA/p/5479131.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Android开发——Activity销毁时异步任务的保存和恢复、以及相关的进度条的显示问题
- Android中通过Handler实现进度条的实时更新
- android当触碰屏幕时ProgressDialog进度条对话框就消失了的解决方法
- Android实战教程第二篇之简单实现两种进度条效果
- android web view的学习 2 通过WebChomeClient 实现进度条和title,通过WebViewClient 来进行url的拦截,和javascript的交互
- android------(自动调节的进度条+评级测试)SeekBar和RatingBar
- android进度条的样式
- Android Progress进度条代码,进度条刷新问题探讨
- Android笔记-ListView总结(多选框ListViiew,动态加载,多线程更新ListView中的进度条)
- Android自定义控件:进度条的四种实现方式
- 【Demo实例】Android FTP上传带进度条(优化后代码)
- Android 带进度条的webview
- android,自定义进度条样式,圆环,圆弧
- Android的进度条控件描述
- Android自定义View系列(一)——打造一个爱心进度条
- Android实现标题上显示隐藏进度条效果
- Android:动态设置颜色渐变的进度条
- Android中用图片自定义一个进度条(实现蒙板效果)
- Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)
- ANDROID中自定义ADAPTER实现LISTVIEW动态刷新进度条