首页 > 解决方案 > MaterialDesign TextInputLayout 缩放问题

问题描述

当我运行 360x640 时,它看起来很完美,但是当我使用更高分辨率时,它开始看起来像这样:

在此处输入图像描述

代码:

  // TOP INPUT
       <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/dob_input_layout"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:focusable="false"
                    android:hint="@string/date_of_birth"
                    app:endIconDrawable="@drawable/ic_more_arrow"
                    app:endIconMode="custom"
                    app:layout_constraintEnd_toEndOf="@+id/bottom_text"
                    app:layout_constraintStart_toStartOf="@+id/bottom_text"
                    app:layout_constraintTop_toBottomOf="@+id/bottom_text">
    
                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/dob_input_et"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:focusable="true"
                        android:hint="@string/_12_15_2000"
                        android:importantForAutofill="no"
                        app:layout_constraintBottom_toTopOf="@+id/last_name_layout_input"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0.5"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/bottom_text" />
                </com.google.android.material.textfield.TextInputLayout>
    
    // BOTTOM INPUT
                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/phoneNumber_input_layout"
                    style="@style/TextInputLayoutTransparent"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:focusable="false"
                    android:hint="@string/phone_number"
                    android:paddingTop="8dp"
                    app:endIconDrawable="@drawable/ic_more_arrow"
                    app:endIconMode="custom">
    
                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/phoneNumber_input_et"
                        style="@style/text_input_black_left"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:ems="10"
                        android:focusable="false"
                        android:hint="@string/set_your_phone_number"
                        android:importantForAutofill="no"/>
                </com.google.android.material.textfield.TextInputLayout>

我尝试的是在 TextInputLayout 和 TextInputEditText 之间使用一些自定义填充,但它没有任何改变。第一个输入是默认样式,另一个是自定义样式,这是我认为值得研究的另一件事。


编辑

<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>

style-v27 及更高版本中存在的这个小小鬼正在产生这种效果,当我摆脱它时,它看起来很完美。任何人都知道可能是什么原因?

标签: androidandroid-layoutmaterial-designandroid-textinputlayoutandroid-textinputedittext

解决方案


推荐阅读