progressDialog 自定义
(1)自定义DefineProgressDialog类,继承ProgressDialog,复写onCreate()方法
public class DefineProgressDialog extends ProgressDialog{ private String message; private TextView define_progress_msg; public DefineProgressDialog(Context context) { super(context); message = "正在载入..."; // TODO Auto-generated constructor stub } public DefineProgressDialog(Context context,String message){ super(context); this.message = message; } @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.define_progress_dialog); define_progress_msg = (TextView) findViewById(R.id.define_progress_msg); define_progress_msg.setText(message); } }
(2)define_progress_dialog.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/progress_background" android:orientation="vertical" android:paddingBottom="10sp" android:paddingTop="10sp" android:paddingLeft="10sp" android:paddingRight="10sp" > <ProgressBar android:id="@+id/ios_progressbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" style="@style/DefineprogressBarStyleSmall"/> <TextView android:id="@+id/define_progress_msg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:textSize="12sp"/> </LinearLayout>
(3)设置进度条样式,自定义DefineprogressBarStyleSmall:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="DefineprogressBarStyleSmall" parent="android:style/Widget.ProgressBar"> <item name="android:indeterminateDrawable">@drawable/progress</item> <item name="android:minWidth">48dp</item> <item name="android:maxWidth">48dp</item> <item name="android:minHeight">48dp</item> <item name="android:maxHeight">48dp</item> </style> </resources>
(4)再定义一个进度条背景图片,设置该图片的动画,绕中心点旋转,在drawable下添加progress.xml:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <rotate android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360" android:drawable="@drawable/progress_round" > </rotate> </item> </layer-list>
相关推荐
xz0mzq 2011-08-17
larrywangsun 2011-08-09
缘来如此 2018-10-18
coosea 2012-09-08
bible 2012-07-22
iqingfen 2012-03-06
wangkuifeng0 2012-03-04
Ifree团队 2012-02-25
ITDHW 2011-07-17
androidstudyroom 2011-05-16
yeaperyeo 2010-11-30
python大数据 2010-10-07
karolee 2010-08-27
PHP100 2019-03-27