Skip to content

Commit 501ae36

Browse files
paulfthomasdsn5ft
authored andcommitted
[DatePicker] Fix arrangement of range text fields
- gives enough space for the text to not wrap when width too narrow PiperOrigin-RevId: 632262914
1 parent b301a58 commit 501ae36

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

lib/java/com/google/android/material/datepicker/res/layout/mtrl_picker_text_input_date.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
<com.google.android.material.textfield.TextInputLayout
2727
android:id="@+id/mtrl_picker_text_input_date"
2828
android:layout_width="match_parent"
29-
android:layout_height="wrap_content">
29+
android:layout_height="wrap_content"
30+
android:minWidth="@dimen/material_textinput_min_width_with_label"
31+
android:maxWidth="@dimen/material_textinput_max_width"
32+
android:layout_gravity="center_horizontal">
3033

3134
<com.google.android.material.textfield.TextInputEditText
3235
android:layout_width="match_parent"

lib/java/com/google/android/material/datepicker/res/layout/mtrl_picker_text_input_date_range.xml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@
2020
<LinearLayout
2121
android:layout_width="match_parent"
2222
android:layout_height="wrap_content"
23-
android:paddingTop="16dp"
23+
android:paddingTop="@dimen/mtrl_calendar_text_input_padding_top"
2424
android:paddingBottom="16dp"
2525
android:paddingLeft="@dimen/mtrl_calendar_content_padding"
2626
android:paddingRight="@dimen/mtrl_calendar_content_padding"
27-
android:orientation="horizontal">
27+
android:orientation="vertical">
2828

2929
<com.google.android.material.textfield.TextInputLayout
3030
android:id="@+id/mtrl_picker_text_input_range_start"
3131
android:layout_width="match_parent"
3232
android:layout_height="wrap_content"
33-
android:layout_weight="1">
33+
android:minWidth="@dimen/material_textinput_min_width_with_label"
34+
android:maxWidth="@dimen/material_textinput_max_width"
35+
android:layout_gravity="center_horizontal">
3436

3537
<com.google.android.material.textfield.TextInputEditText
3638
android:layout_width="match_parent"
@@ -41,14 +43,16 @@
4143
</com.google.android.material.textfield.TextInputLayout>
4244

4345
<Space
44-
android:layout_width="8dp"
45-
android:layout_height="0dp"/>
46+
android:layout_width="0dp"
47+
android:layout_height="8dp"/>
4648

4749
<com.google.android.material.textfield.TextInputLayout
4850
android:id="@+id/mtrl_picker_text_input_range_end"
4951
android:layout_width="match_parent"
5052
android:layout_height="wrap_content"
51-
android:layout_weight="1">
53+
android:minWidth="@dimen/material_textinput_min_width_with_label"
54+
android:maxWidth="@dimen/material_textinput_max_width"
55+
android:layout_gravity="center_horizontal">
5256

5357
<com.google.android.material.textfield.TextInputEditText
5458
android:layout_width="match_parent"

lib/java/com/google/android/material/textfield/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<!-- Minimum width for text fields without a label. If a label is present,
2525
minimum width should be 88dp. -->
2626
<dimen name="material_textinput_min_width">56dp</dimen>
27+
<dimen name="material_textinput_min_width_with_label">88dp</dimen>
2728
<dimen name="material_textinput_max_width">488dp</dimen>
2829

2930
<dimen name="mtrl_textinput_outline_box_expanded_padding">16dp</dimen>

0 commit comments

Comments
 (0)