loading android
16lz
2021-01-23
drawal/loading.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate android:drawable="@drawable/share_popout_icon_loading" android:pivotX="50.0%" android:pivotY="50.0%"
xmlns:android="http://schemas.android.com/apk/res/android" />
、、-------------------------------------------------------------
总觉的自带的progressdialog很丑,所以为了让自己看着舒服一些,不得以就得自己定义样式了,自定义Progressdialog其实很简单,一个layout文件,一个shape文件
再来,然后再有一个资源文件就可以了。
一下是代码
自定义Progressdialog布局文件
[html] view plain copy- <?xmlversion="1.0"encoding="utf-8"?>
- <FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg_dialog_shape"
- android:gravity="center">
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center_horizontal"
- android:orientation="vertical">
- <ProgressBar
- android:id="@+id/oahprogressbar"
- style="@android:style/Widget.ProgressBar.Small"
- android:layout_width="30dip"
- android:layout_height="30dip"
- android:indeterminateDrawable="@drawable/progress"/>
- <TextView
- android:id="@+id/oaprogresstitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dip"
- android:gravity="center_vertical"
- android:text="正在验证..."
- android:textColor="@color/white"/>
- </LinearLayout>
- </FrameLayout>
ProgressBar
[html] view plain copy- indeterminateDrawable的属性
- <?xmlversion="1.0"encoding="utf-8"?>
- <rotatexmlns:android="http://schemas.android.com/apk/res/android">
- <rotatexmlns:android="http://schemas.android.com/apk/res/android"
- android:drawable="@drawable/loading"<!--这就是一张图片,不需要每一个状态一张图片-->
- android:pivotX="50%"
- android:pivotY="50%"/>
- </rotate>
重写ProgressDialog ,
- packagecom.zl.dialog.view;
- importcom.zl.payslip.R;
- importandroid.app.Dialog;
- importandroid.app.ProgressDialog;
- importandroid.content.Context;
- importandroid.os.Bundle;
- /**
- *@authorgqs
- *@version创建时间:2012-11-23上午10:59:43
- *类说明
- */
- publicclassMyDialogextendsProgressDialog{
- publicPaySlipDialog(Contextcontext,inttheme){
- super(context,theme);
- //TODOdvsdfads
- }
- publicPaySlipDialog(Contextcontext){
- super(context);
- //TODOsdfsdf
- }
- @Override
- protectedvoidonCreate(BundlesavedInstanceState){
- //TODOAuto-generatedmethodstub
- super.onCreate(savedInstanceState);
- //progressDialog.setIndeterminate(true);
- setCancelable(false);
- //progressDialog.show()
- setContentView(R.layout.progressdialog_layout);
- }
- publicvoidshowDialog()
- {
- show();
- }
- }
最后在Acivity里面直接调用就行了
public void showDialog(Context context)
{
MyDialog dialog = new MyDialog(context);
dialog.showDialog();
}
更多相关文章
- Android实现图片缩放与旋转
- Android Studio点击按钮更换背景图片
- AndroidMenifest.xml(Android清单文件)内部代码分析
- android图片放大 缩小 旋转
- Android布局文件中的属性含义
- Android 怎么给图片添加一个边框
- Android开发进阶:如何读写Android文件
- android studio 使用adb命令传递文件到android设备
- 第三课:android数据相关---文件