当前位置: 首页 > 知识库问答 >
问题:

具有AlertDialog样式的对话框

颛孙高义
2023-03-14

在我的项目中,我需要使用自定义对话框,而不是AlertDialog。但我有两个问题与对话框风格:

  1. 宽度太小
  2. 我无法删除标题空间

所以,我需要

但是你可以得到:

呼叫代码:

Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.write_message);
dialog.show();

布局XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <EditText
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textMultiLine"
        android:minLines="3" >

        <requestFocus />
    </EditText>


    <Button
        android:id="@+id/send_message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/send_message" />

</LinearLayout>

如何解决这个问题?请帮帮忙。

共有1个答案

夔宏深
2023-03-14

您是否尝试过:

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //for the title space

dialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); //for the width

如果需要,可以在布局xml中添加填充

 类似资料:
  • 继承自Popup 对话框是一个原生对话弹出框,显示一个消息与最多三个按钮。关闭时会被自动释放。 使用“const {AlertDialog} = require('tabris');”引入该类。 属性 buttons Type: {ok?: string, cancel?: string, neutral?: string} 含有按钮文本内容的对象。分别是这三种按钮:ok, cancel和neut

  • 问题内容: 我有一个活动,其底部有一个“保存并取消”按钮。 在AlertDialog中,按钮显示在某种样式的容器视图内。 我怎样才能使“活动”中的按钮具有相同的外观?具体来说,如何在AlertDialog中应用按钮容器视图的样式,在包含按钮的Activity中说一个LinearLayout? 谢谢 问题答案: 我做这样的事情: 然后,我使用dialogLayout调用findViewById()来

  • 主要内容:本节引言:,1.基本使用流程,2.几种常用的对话框使用示例,3.通过Builder的setView()定制显示的AlertDialog,4.示例代码下载,本节小结:本节引言: 本节继续给大家带来是显示提示信息的第三个控件AlertDialog(对话框),同时它也是其他 Dialog的的父类!比如ProgressDialog,TimePickerDialog等,而AlertDialog的父类是:Dialog! 另外,不像前面学习的Toast和Notification,AlertDialo

  • 本文向大家介绍Android Alertdialog(实现警告对话框),包括了Android Alertdialog(实现警告对话框)的使用技巧和注意事项,需要的朋友参考一下 在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择。这些功能我们叫它Android Dialog对话框,AlertDialog实现方法为建造者模式。下面我们模拟卸载应用程序

  • 本文向大家介绍Android AlertDialog实现分享对话框/退出对话框/下载对话框,包括了Android AlertDialog实现分享对话框/退出对话框/下载对话框的使用技巧和注意事项,需要的朋友参考一下 一.摘要 弹窗通常用于提示用户进行某种操作,比如:点击分享按钮,弹窗分享对话框;双击返回按钮,弹窗退出对话框;下载文件,提示下载对话框等等,分享对话框/退出对话框/下载对话框,都可以直

  • 我正在寻找一种方法来设置默认JavaFX对话框(。 我尝试获取对话框窗格并添加样式表,但它只覆盖了对话框的一小部分。我更喜欢只使用外部css文件进行样式设计,而不在代码上添加样式类。这看起来很混乱(标题、内容、内容上的自有内容等等) 我已经在谷歌上搜索了很多,只找到了ControctionFX的例子,但是由于jdk8_40 JavaFX有自己的Dialogs,我现在使用它们。 有什么建议吗? 编辑