Android 自定义简单实用Dialog
public class WaitingDialog extends Dialog {private TextView tv_text;public WaitingDialog(Context context) {super(context);getWindow().setBackgroundDrawable(new ColorDrawab
·
public class WaitingDialog extends Dialog {
private TextView tv_text;
public WaitingDialog(Context context) {
super(context);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setContentView(R.layout.waiting_layout);
tv_text = (TextView) findViewById(R.id.tv_text);
setCanceledOnTouchOutside(false);
}
public WaitingDialog setMessage(String message) {
tv_text.setText(message);
return this;
}
}
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<RelativeLayout
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:background="#20000000"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|bottom"
android:orientation="vertical">
<ProgressBar
style="@android:style/Widget.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:text="@string/dealing"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
更多推荐
所有评论(0)