Android高级UI ProgressBar实现各种效果的圆形进度
2016-05-30 09:09
671 查看
内容
包含小、中、大的圆形进度条包含水平进度条
什么是命名空间?
Android的xmlns,这个是XML Namespaces的缩写,中文名称是XML(标准通用标记语言的子集)命名空间链接:http://blog.sina.com.cn/s/blog_a28e3dd90102uxmc.html
布局
依次为:圆形进度条:小
圆形进度条:中
圆形进度条:大
水平进度条:一级进度条
水平进度条:二级进度条
二级进度条控制按钮
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.feather.androiddemos.ProgressBarActivity"> <ProgressBar style="?android:attr/progressBarStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ProgressBar style="?android:attr/progressBarStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ProgressBar style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ProgressBar android:id="@+id/progress_one_level_bar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="100pt" android:layout_height="wrap_content" android:max="100" android:progress="30" /> <!--max为最大进度,progress为当前一级进度,secondaryProgress为当前二级进度--> <ProgressBar android:id="@+id/progress_two_level_bar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="100pt" android:layout_height="wrap_content" android:max="100" android:progress="30" android:secondaryProgress="50" /> <Button android:id="@+id/progress_one_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="单级进度条" /> <Button android:id="@+id/progress_two_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="二级进度条" /> </LinearLayout>
Java代码
public class ProgressBarActivity extends AppCompatActivity { Button oneButton; Button twoButton; ProgressBar progressBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_progress_bar); oneButton = (Button) findViewById(R.id.progress_one_button); //增加进度按钮 twoButton = (Button) findViewById(R.id.progress_two_button); //减少进度按钮 progressBar = (ProgressBar) findViewById(R.id.progress_two_level_bar); //二级进度条 oneButton.setOnClickListener(new buttonListenner()); //设置监听器 twoButton.setOnClickListener(new buttonListenner()); } class buttonListenner implements View.OnClickListener{ @Override public void onClick(View v) { switch (v.getId()){ case R.id.progress_one_button: //增加一级和二级进度条 progressBar.incrementProgressBy(10); progressBar.incrementSecondaryProgressBy(10); break; case R.id.progress_two_button: //减少进度条 progressBar.incrementProgressBy(-10); progressBar.incrementSecondaryProgressBy(-10); break; } } } }
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories