在安卓系统中,自定义对话框在顶部会出现空白的情况。

3

我正在开发一款应用程序,为了确认目的,我实现了一个自定义对话框,我已经为对话框创建了一个自定义布局,但它在顶部有一个白色空间,请问有人能帮我去掉它吗? XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_gravity="center"
    android:gravity="center"
    android:background="@drawable/bg_et_selected"
    android:layout_width="300dp" android:layout_height="170dp">

   <RelativeLayout

       android:layout_width="300dp"
       android:layout_height="170dp">
       <TextView
           android:id="@+id/tv_hdr"
           android:layout_width="fill_parent"
           android:layout_height="40dp"
           android:background="#31E2D9"
           android:layout_alignParentTop="true"
           android:text="Report"
           android:textSize="22dp"
           android:gravity="center"
           android:textColor="#ffffff"
           android:textStyle="bold"
           />

       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:textSize="22dp"
           android:layout_below="@+id/tv_hdr"
           android:layout_marginTop="20dp"
           android:gravity="center"
           android:textStyle="bold"
           android:text="Are you sure want to report this post?"
           android:layout_centerHorizontal="true"
           android:textColor="#545454"
           android:id="@+id/tv_title" />

       <LinearLayout
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_alignParentBottom="true"
           android:weightSum="2"
           >
           <Button
               android:id="@+id/btn_ok"
               android:layout_width="wrap_content"
               android:layout_height="35dp"
               android:text="YES"
               android:textStyle="bold"
               android:textColor="#ffffff"
               android:background="@drawable/btn_selector"
               android:layout_weight="1"/>

           <View
               android:layout_width="1dp"
               android:layout_height="30dp"
               android:background="#ffffff"/>

           <Button
               android:id="@+id/btn_cancel"
               android:layout_width="wrap_content"
               android:layout_height="35dp"
               android:text="NO"
               android:textStyle="bold"
               android:textColor="#ffffff"
               android:background="@drawable/btn_selector"
               android:layout_weight="1"/>    
       </LinearLayout>

   </RelativeLayout>

</RelativeLayout>

你确定它不是一个空的对话框标题,下面有一条蓝线吗?别把这当成侮辱。只是确认一下。 - Malith Lakshan
1个回答

8
我已经自己修复了,我从代码中删除了对话框标题并进行了修复,请参见此处。
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_report);

之前它为头部留出了一个空白的空间。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接