0

I am trying to add a DatePicker to a view but whatever change it doesn't change its width. What I have done is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/common_view_height"
    android:background="@color/orange"
    android:orientation="horizontal"
    android:paddingEnd="@dimen/common_margin_16"
    android:paddingStart="@dimen/common_margin_16">

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:fontFamily="@font/worksansmedium"
        android:gravity="center_vertical"
        android:text="@string/date_selection_heading"
        android:textColor="@color/white"
        android:textSize="@dimen/text_size_extra_large" />

    <TextView
        android:id="@+id/txt_date_selection_done"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:fontFamily="@font/worksansmedium"
        android:gravity="center_vertical"
        android:text="@string/date_selection_done"
        android:textColor="@color/white"
        android:textSize="@dimen/text_size_extra_large" />

</LinearLayout>

<DatePicker
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:headerBackground="@color/orange" />

If it is a TimePicker it will take the entire screen. Why is that happing?

enter image description here

DKV
  • 1,767
  • 3
  • 28
  • 49
  • Possible duplicate of [how to override height and width of date picker to fill the parent layout](https://stackoverflow.com/questions/47467550/how-to-override-height-and-width-of-date-picker-to-fill-the-parent-layout) – Thomas Mary Mar 22 '18 at 10:12
  • @ThomasMary : scaling is not a proper way. it will not work for all device – DKV Mar 22 '18 at 10:48
  • Remove **Orientation** in main LinearLayout – Ali Mar 22 '18 at 11:41
  • Hi @DKV did you manage to find a proper solution for this? – Kartik Dec 03 '19 at 08:21

0 Answers0