I have a problem in DatePicker on android I can't make it smaller than default size
This is the XML code which used:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<DatePicker
android:id="@+id/datePicker1"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/addevent_location" />
</RelativeLayout>
Any help please
I haven't been able to figure out a way to resize it, but have seen implementations where they utilize the DatePicker as a dialog. The date is rendered as TextView with an edit button, which launches the DatePicker dialog. It saves screen real estate when not editing...
http://developer.android.com/resources/tutorials/views/hello-datepicker.html
As far as I know, the DatePicker
widget itself cannot be re-sized, back when I started Android I tried various ways of getting it smaller, but without any results.
If your looking to gain screen real estate by making it smaller, I would suggest you use either the DatePickerDialog
or one of a many available custom pickers that developers have created (many of them are available on the web and most are well built and customizable).
Here's a link to get you started with the DatePickerDialog
if you're not familiar with this widget.
No. You cannot reduce the size of a view beyond their minimum size. Using wrap_content ensures that the DatePicker is just big enough to enclose its contents.
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>