android 使用代码方式创建自定义progressBar——自定义控件学习(六)
来源:互联网 发布:合众思壮软件 编辑:程序博客网 时间:2024/05/21 15:34
android 使用代码方式创建自定义progressBar——自定义控件学习(六)
本文主要参考:http://blog.csdn.net/hjj0212/article/details/8286757
因为在自定义控件的时候经常需要整合progressBar,所以需要自己通过代码的方式创建一个progressBar,而且通常情况下,需要对progressBar的颜色大小进行设置。下面就直接上货:
1、首先是布局文件:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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" tools:context="com.example.administrator.customerprogressbar.MainActivity"></RelativeLayout>
2、可能需要的资源:
progressbar.xml
<?xml version="1.0" encoding="utf-8"?><animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360"> <shape android:shape="ring" android:innerRadiusRatio="3" android:thicknessRatio="8" android:useLevel="false"> <gradient android:type="sweep" android:useLevel="false" android:startColor="#EEEEEE" android:centerColor="#CCCCCC" android:centerY="0.50" android:endColor="#AAAAAA" /> </shape></animated-rotate>
3、MainActivity.java
package com.example.administrator.customerprogressbar;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.ProgressBar;import android.widget.RelativeLayout;public class MainActivity extends AppCompatActivity { private ProgressBar progressBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progressBar = new ProgressBar(this); progressBar.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progressbar)); this.addContentView(progressBar,new RelativeLayout.LayoutParams(100,100)); }}
代码还是比较基本的,所以不过多的解释了,下面是运行结果:
0 0
- android 使用代码方式创建自定义progressBar——自定义控件学习(六)
- 【android自定义控件】ProgressBar自定义
- Android 自定义View——自定义ProgressBar
- Android 自定义View——自定义ProgressBar
- android学习七(创建自定义控件)
- android学习笔记——创建自定义控件
- 六.Android自定义控件
- Flex企业应用开发实践学习笔记(六)——使用ActionScript创建自定义组件
- Android 自定义学习(5)自定义Progressbar
- Android自定义view之下载控件,ProgressBar
- Android自定义控件---继承ProgressBar功能扩展
- 编写Qt Designer自定义控件(一)——如何创建并使用Qt自定义控件
- 编写Qt Designer自定义控件(一)——如何创建并使用Qt自定义控件
- 编写Qt Designer自定义控件(一)——如何创建并使用Qt自定义控件
- 编写Qt Designer自定义控件(一)——如何创建并使用Qt自定义控件
- 编写Qt Designer自定义控件(一)——如何创建并使用Qt自定义控件
- 自定义控件之-----progressBar
- 自定义控件之-----progressBar
- Android从零开始构建项目之目录结构
- linux-守护进程的编写
- cocoscreator在mac下火狐浏览器运行 cc.log查看
- jQuery-easyUI的配置
- android 图片处理(压缩与缓存)
- android 使用代码方式创建自定义progressBar——自定义控件学习(六)
- Java:按值传递还是按引用传递详细解说
- xcode真机调试出现证书被revoke提示
- POJ 2823 Sliding Window
- java中几种文件流的使用方法
- Vysor PRO 破解方法
- cocos2d-x 3.10 C++加载动画
- 使用Carthage管理iOS依赖库
- facetest