如何从自定义对话框中删除标题?

我实现了一个布局,以便成为我的自定义对话框布局,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:background="@color/gray_back"
   xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
    android:id="@+id/mainLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="20dp"
    android:layout_centerInParent="true">

    <ImageView
        android:src="@drawable/user"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="center"
        android:layout_gravity="center"
        android:contentDescription="@string/app_name" />

    <EditText
        android:id="@+id/username"
        android:background="@android:color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:layout_marginBottom="20dp"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:gravity="center"
        android:layout_gravity="center"
        android:hint="@string/new_profile_name" />

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="?android:attr/dividerHorizontal" />

</LinearLayout>

<LinearLayout
    style="?android:attr/buttonBarStyle"
    android:layout_below="@id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingTop="0dip"
    android:measureWithLargestChild="true">

    <Button
        android:id="@+id/cancel"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Cancel"/>
    <Button
        android:id="@+id/ok"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Ok"/>
</LinearLayout>

我以编程方式创建了它,如下所示:

final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_add_profile);

Button dialogButton = (Button) dialog.findViewById(R.id.cancel);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
         dialog.dismiss();
       }
   });
 dialog.show();

但是然后我的对话框显示如下:

在此处输入图片说明

如何删除图像到布局顶部的剩余空间?

我想尝试一下:

dialog.setWindowFeature(Window.WINDOW_NO_TITLE);

但它崩溃了...我该如何删除剩余空间?

赛义德·贾萨尼(Saeed Jassani)

创建一个新样式,添加:

<style name="NoTitleDialog" parent="@android:Theme.Dialog">
<item name="android:windowNoTitle">true</item> </style>

最后:

Dialog d = new Dialog(this, R.style.nameOfStyle);

编辑:这个答案

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何从自定义对话框中删除标题?

来自分类Dev

如何从自定义对话框中删除标题?

来自分类Dev

删除标题后,自定义对话框崩溃

来自分类Dev

如何自定义对话框的标题部分

来自分类Dev

如何自定义对话框的标题部分

来自分类Dev

在自定义对话框中删除警报对话框边框

来自分类Dev

DatePicker的内容与自定义对话框的标题重叠

来自分类Dev

DatePicker的内容与自定义对话框的标题重叠

来自分类Dev

JavaFX对话框标题颜色自定义

来自分类Dev

如何在install4j中自定义初始进度对话框的标题文本?

来自分类Dev

如何在自定义对话框中设置自定义按钮?

来自分类Dev

如何在自定义对话框中设置自定义按钮?

来自分类Dev

如何使用自定义确认对话框通过 dropzone 删除多个上传的文件?

来自分类Dev

如何在自定义对话框中添加微调框并使用数组填充它

来自分类Dev

如何更改打开对话框的图像以及如何自定义对话框?

来自分类Dev

如何自定义放置Jquery对话框

来自分类Dev

如何制作更好的自定义对话框?

来自分类Dev

如何制作自定义Cast MediaRouter对话框

来自分类Dev

WPF:如何使自定义模式对话框闪烁?

来自分类Dev

如何创建自定义材质对话框

来自分类Dev

DialogResult或如何创建自定义对话框

来自分类Dev

如何创建自定义对话框

来自分类Dev

如何自定义对话框宽度?

来自分类Dev

Electron中的自定义HTML对话框

来自分类Dev

在Chain Wix中插入自定义对话框

来自分类Dev

在自定义对话框中设置textview

来自分类Dev

在自定义对话框中填充NumberPicker

来自分类Dev

FB共享对话框中的自定义消息

来自分类Dev

可可中的自定义下拉窗口/对话框

Related 相关文章

热门标签

归档