【发布时间】:2015-01-12 17:04:16
【问题描述】:
我有一个自定义的DialogPreference,它只包含一个日期选择器。一切正常,除了对话框有一个巨大的边框和标题,如下所示。
我希望对话框只是日期选择器:
我已经想出了如何通过将窗口标题设置为空来删除标题,但是大边框仍然存在。
我的自定义布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<DatePicker
android:id="@+id/birthdayPicker"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:calendarViewShown="false"/>
</LinearLayout>
我尝试将线性布局的宽度/高度设置为 wrap_content、设置负边距以及许多其他 hackey 解决方案,但似乎没有任何效果。
到目前为止,我唯一的运气是覆盖 onShow 并以编程方式将窗口大小设置为任意数量 - 例如 300dp 的宽度。这显然是超级骗子,我更喜欢更优雅的解决方案。任何帮助将不胜感激!
【问题讨论】:
-
为什么你的
LinearLayout的宽度和高度都有match_parent? -
可能是
wrap_content用于您的 LinearLayoutlayout_width? -
我目前发现了同样的问题,使用 TimePicker 而不是 DatePicker。你有没有找到解决这个问题的方法?你介意分享
onShowhack吗?
标签: java android android-layout android-5.0-lollipop