android - 自定义对话框在 android 顶部提供空白

标签 android android-alertdialog customdialog

我正在开发一个应用程序,我已经实现了一个用于确认目的的自定义对话框,我已经为该对话框创建了一个自定义布局,但它的顶部有空白,有人可以帮我删除它吗? 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>

最佳答案

我已经自己修复了它,我已经从代码中删除了对话框标题并修复了,请看这里。

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_report);

以前它给我空白的标题空间。

关于android - 自定义对话框在 android 顶部提供空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37361626/

相关文章:

android - 在 ViewPager2 android 中检测过度滚动或页面结束事件

android - 在 Activity 中实现多个警报对话框的最佳方式

android - 获取与 Activity 相关的错误未在 fragment 中运行

java - Android 联系信息有意更新?

android - ListView 的屏幕截图并将其转换为位图

android - 在对话框之间显示 ProgressDialog

java - 如何检查哪些复选框已选中,哪些未选中?

xaml - 如何显示 Callisto WinRT 工具包中的自定义对话框?

ios - 在 iOS 中创建这样的自定义对话框?

java - 无法创建目录