android自定义ProgressDialog
来源:互联网 发布:投诉淘宝店家有用吗 编辑:程序博客网 时间:2024/06/15 11:13
本文主要介绍自动环形的ProgressDialog,主要用于网络请求之前的缓冲页面。
首先对ProgressDialog进行分解,它分为一个ProgressBar和一个TextView,因此我们最主要的就是自定义ProgressBar
自定义ProgressDialog的主要布局文件buffer_dialog.xml,主要的作用是让dialog在屏幕的中间位置显示
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ProgressBar android:id="@+id/bufferdialog_progressbar" style="@style/StyleBufferDialoglarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminateDuration="700" android:layout_centerInParent="true" /> <TextView android:id="@+id/bufferdialog_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/bufferdialog_progressbar" android:layout_marginTop="25dp" android:layout_centerHorizontal="true" android:textColor="@color/white" android:textSize="20sp" /></RelativeLayout>
<style name="StyleBufferDialoglarge"> <item name="android:indeterminateDrawable">@drawable/drawable_list_dialog</item> <item name="android:minWidth">76dip</item> <item name="android:maxWidth">76dip</item> <item name="android:minHeight">76dip</item> <item name="android:maxHeight">76dip</item> <item name="android:windowBackground">@android:color/white</item> </style>
通过动画配置文件来绘制进度条与它的动画效果,如下
<?xml version="1.0" encoding="utf-8"?><animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/loading_animation_dialog" android:pivotX="50.0%" android:pivotY="50.0%" android:fromDegrees="0" android:toDegrees="360" />
loading_animation_dialog.png就是随意一张圆形图片即可
public class BufferDialog extends AlertDialog {private Context mContext;private TextView mMessageView;public BufferDialog(Context context) {super(context);this.mContext = context;}public BufferDialog(Context context, int theme) {super(context, theme);this.mContext = context;}@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);LayoutInflater inflater = LayoutInflater.from(mContext);View view = inflater.inflate(R.layout.buffer_dialog, null);mMessageView = (TextView) view.findViewById(R.id.bufferdialog_message);if (message != null)mMessageView.setText(message);setContentView(view);}private CharSequence message;@Overridepublic void setMessage(CharSequence message) {this.message = message;}}
如此就简单实现了自定义ProgressDialog.
0 0
- Android ProgressDialog 自定义
- android 自定义progressDialog实现
- android 自定义progressDialog实现
- Android 自定义ProgressDialog
- Android 自定义progressDialog实现
- Android 自定义ProgressDialog
- Android 自定义ProgressDialog
- Android 自定义ProgressDialog
- Android 自定义progressDialog实现
- Android 自定义progressDialog实现
- Android 自定义progressDialog实现
- Android 自定义progressDialog实现
- Android ProgressDialog 自定义方法
- Android 自定义progressDialog实现
- Android 自定义progressDialog实现
- Android 自定义progressDialog实现
- Android 自定义progressDialog实现
- 自定义android ProgressDialog
- 多个catch捕获异常顺序
- 学习英语的美剧
- 学习python的目的
- 拖延心理学摘要
- Objective - C基础: 第四天 - 10.SEL类型的基本认识
- android自定义ProgressDialog
- 注意for循环中变量的作用域
- Codeforces Round #287 (Div. 2)B(几何)
- 2025哦我他妈的就是一个大煞笔啊卧槽!
- PostgreSQL每日一贴--PL/pgSQL存储过程示例
- jquey表单序列化
- [Java][Spring]Spring事务不起作用 问题汇总
- 计算机系统导论
- UIView Api