I have a custom DialogPreference
that just contains a date picker. Everything works fine EXCEPT the dialog has a huge border and title around it as can be seen below.
I would like the dialog to just be the date picker:
I've figured out how to remove the title by setting the window title to null, but the massive border still exists.
My custom layout:
<?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>
I've tried setting the linear layouts width/height to wrap_content
, setting negative margins, and a host of other hackey solutions but nothing seems to be working.
The only luck I've had so far is overriding onShow
and programmatically setting the windows size to some arbitrary amount - like a width of 300dp. This is obviously super duper hackey and I'd prefer a more elegant solution. Any help would be much appreciated guys!
<?xml version="1.0" encoding="utf-8"?>
Your LinearLayout
should not be match_parent
but wrap_content
eg the DatePicker
's dimensions.
Try:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.