开发者社区> 问答> 正文

android 自定义AsAlertDialog不能全屏

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>

展开
收起
爵霸 2016-06-12 14:05:33 2886 0
1 条回答
写回答
取消 提交回答
  • 重写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);
       }
    2019-07-17 19:33:56
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载