Search code examples
androiddatetimepicker

View is cutting when run on phone emulator


I am developing an app for mobile phone, in that I needed one date & time picker, and since android does not provide both I created my custom one. but when I am adding both date picker and time picker, time picker is cutting. I don't know why. Although its running fine on tablet (as I tried it), but on phone its cutting for obvious reason. Can any body help me.

This is what I am getting.My Image

My code is

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="5dp" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="horizontal" >
        <DatePicker
            android:id="@+id/dp_date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal" />
        <TimePicker
            android:id="@+id/tp_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <Button
            android:id="@+id/btn_date_time_ok"
            style="@style/Text.Medium"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="@string/ok" />
        <Button
            android:id="@+id/btn_date_time_cancel"
            style="@style/Text.Medium"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="@string/cancel" />
    </LinearLayout>

</LinearLayout>

Can any one suggest me something that it both picker adjust itself to screen. O r am I missing something. Any help will be appreciated. Thanks in advance.

EDIT

Is there some way to reduce the size of text used in date and time picker????


Solution

  • Thanks for all the answers, Bu finally I resolved my problem. I am using different layout files for my phone device, so that Layout comes in proper fashion. Thanksfor all effort