jav代码:
AsAlertDialog progressDialog = null;
LayoutInflater inflater = LayoutInflater.from(getActivity());
View v1 = inflater.inflate(R.layout.progress_dialog_item, null);// 得到加载view
RelativeLayout layout = (RelativeLayout) v1.findViewById(R.id.dialog_view);// 加载布局
AsAlertDialog.Builder builder = new AsAlertDialog.Builder(getActivity());
progressDialog = builder.create();
progressDialog.show();
progressDialog.setContentView(layout,new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT));
xml代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/dialog_view" >
<RelativeLayout
android:id="@+id/progress_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:background="#00000000" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
> <ProgressBar
android:id="@+id/process_bar"
style="?android:attr/progressBarStyle"
android:layout_width="50px"
android:layout_height="50px"
android:layout_centerVertical="true"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/loading_process"
android:indeterminateDuration="500"
android:indeterminateOnly="true"
android:interpolator="@android:anim/linear_interpolator" />
<TextView
android:id="@+id/progress_textview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10px"
android:layout_toRightOf="@id/process_bar"
android:gravity="center_vertical"
android:text="@string/weather_waiting"
android:textColor="#FFFFFF"
android:textSize="24px" />
</LinearLayout>
</RelativeLayout>
重写Dialog,重写onCreate方法,在里面设置,如下:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
window.setGravity(Gravity.BOTTOM);
window.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。