[英]Android DialogPreference width
我有一個僅包含日期選擇器的自定義DialogPreference
。 除了對話框具有巨大的邊框和標題之外,其他所有內容都可以正常運行,如下所示。
我希望對話框只是日期選擇器:
我已經想出了如何通過將窗口標題設置為null來刪除標題的方法,但是大邊框仍然存在。
我的自定義布局:
<?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>
我試過將線性布局的width / height設置為wrap_content
,設置負邊距,以及其他許多hackey解決方案,但似乎沒有任何效果。
到目前為止,我唯一的運氣是重寫onShow
並以編程方式將窗口大小設置為任意大小-例如300dp的寬度。 這顯然是超級騙子hackey,我希望有一個更優雅的解決方案。 任何幫助將不勝感激的家伙!
<?xml version="1.0" encoding="utf-8"?>
您的LinearLayout
不應為match_parent
而應為wrap_content
例如DatePicker
的尺寸。
嘗試:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<DatePicker
android:id="@+id/birthdayPicker"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:calendarViewShown="false"/>
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.