日期选择器未获得match_parent

时间:2018-03-22 10:05:33

标签: android datepicker

我正在尝试向视图添加DatePicker,但无论如何更改都不会更改其width。我所做的是

<?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" />

如果是TimePicker则需要整个屏幕。为什么会这样?

enter image description here

0 个答案:

没有答案