1.新建dialog
public class LoadingViewextends BaseDialog {
@BindView(R.id.id_tv_loading_dialog_text)
TextViewmMessageTxt;
public LoadingView(Context context) {
// super(context);
super(context, R.style.Translucent_NoTitle);
}
public LoadingView(Context context, int theme) {
super(context, theme);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setCancelable(false);
}
@Override
protected int getLayoutId() {
return R.layout.view_loading;
}
@Override
public void show() {
super.show();
if (mMessageTxt !=null) {
mMessageTxt.setText(R.string.loading);
}
}
public void show(String message) {
super.show();
if (mMessageTxt !=null) {
mMessageTxt.setText(message);
}
}
public void show(int msgRes) {
super.show();
if (mMessageTxt !=null) {
mMessageTxt.setText(msgRes);
}
}
}
2.新建style
<style name="Translucent_NoTitle" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item><!--边框-->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
<item name="android:windowIsTranslucent">false</item><!--半透明-->
<item name="android:windowNoTitle">true</item><!--无标题-->
<item name="android:windowBackground">@color/transparent</item><!--背景透明-->
<item name="android:backgroundDimEnabled">false</item><!--模糊-->
</style>
3.view_loading
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_loading_dialog"
android:gravity="center"
android:minHeight="60dp"
android:minWidth="200dp"
android:orientation="vertical"
android:padding="10dp">
style="?android:attr/progressBarStyleSmall"
android:layout_width="50dp"
android:layout_height="50dp"
android:progressDrawable="@mipmap/icon_loading"/>-->
android:layout_width="38dp"
android:layout_height="38dp"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@anim/progressbar_drawable"
android:indeterminateDuration="2000"
android:indeterminateOnly="true" />
android:layout_width="90dp"
android:layout_height="90dp"
android:gravity="center"
android:background="@drawable/round_corner_5dp_80000000"
>
style="?android:attr/progressBarStyleSmall"
android:layout_width="50dp"
android:layout_height="50dp"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@mipmap/icon_loading"
android:indeterminateDuration="1500"
android:indeterminateOnly="true"
/>
-->
android:id="@+id/id_tv_loading_dialog_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="@string/loading"
android:textColor="@color/white"
android:textSize="14sp" />
4,样式动画,progressbar_drawable
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360"
android:drawable="@mipmap/icon_loading">
</rotate>
网友评论