- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
所以在为一个简单的“让用户选择”弹出窗口制作了一个 dialogfragment
之后,我加载了它并在布局中看到了一些奇怪的额外空白,我不确定是什么原因造成的,我已经一直在绞尽脑汁想弄明白。我稍微修改了 xml 以更好地显示行为,唯一的区别是我将 3 个垂直部分的宽度从“match_parent”更改为“wrap_content”,因此我可以使用边框来显示空白的实际大小.这是显示问题的图片:
这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/pictureSourceMainTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Where would you like to choose\nyour image from?"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="@+id/pictureSourceIVLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tvborder"
android:weightSum="3" >
<ImageView
android:id="@+id/pictureSourceCancelIV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/pictureSourceGalleryIV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/pictureSourceCameraIV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:id="@+id/pictureSourceTVLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="@+id/pictureSourceCancelTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Cancel" />
<TextView
android:id="@+id/pictureSourceGalleryTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Gallery" />
<TextView
android:id="@+id/pictureSourceCameraTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Camera" />
</LinearLayout>
</LinearLayout>
所以我的问题是:我该怎么做才能删除这个多余的空格?我的 xml 布局是否缺少某些内容?我每次都可以手动设置宽度的大小,但我更希望窗口本身实际上是“wrap_content”
编辑:原来调整大小是由标题引起的,有没有办法将标题缩小到合适的大小?
最佳答案
罪魁祸首是标题。设置:
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
在我的 dialogfragment 的 oncreateview
中修复了所有大小问题,我只是在顶部添加了一个新的 imageview
并在 photoshop 中设计了我自己的标题。
关于Android DialogFragment 布局,奇怪的额外空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20308359/
我有一个 AppCompatActivity,它在某个时候显示一个 DialogFragment。在此对话框中,有些项目在删除之前需要确认。通过另一个 Yes/No DialogFragment 询问
我们添加一个通用的/普通的 fragment ,以编程的方式做一些事情,比如: fragmentTransaction.add(containerViewId, fragmentToAdd, frag
我有一个 DialogFragment 向用户显示选项列表,其中一个选项是“删除”选项,当用户按下删除选项时我想显示另一个 DialogFragment 作为确认,不幸的是,确认对话框没有显示。 这是
假设我在一个名为 my_dialog_fragment.xml 的 xml 布局文件中指定了 DialogFragment 的布局,并指定了 layout_width 和 >layout_height
当我设置对话框 fragment 的样式时,android 允许截取对话框 fragment 的屏幕截图,但在删除样式后它会起作用。 下面是对话框 fragment 的onCreate代码 @Over
我的应用程序中有一个带有日期和时间字段的 DialogFragment1(由 MyFragmentActivity 调用)。当用户单击它们时,会出现 DatePickerFragment 和 Time
显示 ProgressDialog 时应用程序崩溃。我正在使用滑出式键盘在手机上进行测试。显示对话框时,我滑动键盘,应用崩溃。 public static class ProgressDialogFr
正如问题中提到的.. 我有一个 fragment ,我从中创建并显示一个 DialogFragment,并将 targetFragment 设置为此当前 fragment 。 DialogFragme
如何在此 DialogFragment 中检索 editText1?它存在于 vraag_banen.xml 中,但 getView() 为空。 该对话框显示正常,也没有编译错误,但是我无法弄清楚如何
我应该如何创造这个设计的优越部分? 我正在使用 DialogFragment 在弹出窗口中执行此操作,但无法实现顶部透明的效果。 按钮设计但 background_circle: 使用
最后,我发现问题是什么...... 如果你有这样的功能: public void test() { DialogFragment dlg = new LoginDialog(); dl
我有一个带有监听器的 DialogFragment,用于单击按钮以调用 fragment 中的函数。 我收到 lateinit property listener has not been initi
我在 Activity 上有一个 DialogFragment。此 DialogFragment 是一个由 Web 服务调用填充的 ListView 。单击此 ListView 中的一行后,对话框应消
我正在尝试遵循本教程:http://developer.android.com/guide/topics/ui/controls/pickers.html#DatePicker 这是他们提供的代码,所
有什么方法可以更改 DialogFragment 中正面、负面和中性按钮的显示顺序,以便我可以先放置负面按钮? 我不想改变按钮的“性质”,而是保持它们为“积极”、“消极”和“中性”。 最佳答案 尝试这
这里可能重复,抱歉... 我不知道如何将自定义样式添加到我的 DialogFragment。此刻我正在上课 public final class SelectFragment extends Dial
我花了几个小时来让这个简单的用例正常工作:当我按下音量硬件按钮时,我想打开一个 DialogFragment。该对话框包含一个 SeekBar,应根据按下的按钮进行设置。 我这里有几个问题。 首先,我
DialogFramgment 有问题(在多个 Android 4.2/4.4 设备上支持 v4 库)。 我有两个 DialogFragment:EditAccountDialogFragment 和
当我将有效代码从 fragment 复制到dialogfragment时,它突然不起作用。 在常规 fragment 上:将位图保存在 sd 卡上。 on dialogfragment: 不将位图保存
我花了一整天的时间试图弥补这一点,但我不能.. 这就是问题所在:我想要一个是/否 AlertDialog方向改变时不会消失,所以我决定使用 DialogFragment . 所以我准备了代码并第一次使
我是一名优秀的程序员,十分优秀!