如何在不更改TextInputLayout内部提示填充的情况下仅为EditText设置左填充?

时间:2019-06-24 12:53:56

标签: android android-layout android-edittext android-textinputlayout

当我在TextInputLayout中为EditText设置paddingStart时,浮动提示也向左移动。如何为我的edittext设置填充,以保持TextInputLayout提示默认保留在左侧?

下面是我的代码:

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/cardNumberTil"
    style="@style/AuthTheme.NumberEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="32dp"
    app:hintTextAppearance="@style/CaptionLink">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Some hint here"
            android:imeOptions="actionDone"
            android:inputType="number"
            android:maxLines="1"
            android:paddingStart="45dp"
            android:text="12345678"
            android:textAppearance="@style/Body1Style"
            tools:ignore="HardcodedText" />    
</com.google.android.material.textfield.TextInputLayout>


Here are styles:

<style name="Body1Style">
    <item name="android:fontFamily">@font/sans_serif_regular</item>
    <item name="android:textSize">16sp</item>
    <item name="android:lineSpacingExtra">8sp</item>
    <item name="android:textColor">#000000</item>
</style>

<style name="CaptionLink">
    <item name="android:fontFamily">@font/roboto_regular</item>
    <item name="android:textSize">12sp</item>
    <item name="android:textStyle">normal</item>
    <item name="android:lineSpacingExtra">8sp</item>
    <item name="android:textColor">#0089d0</item>
</style>

<style name="AuthTheme.NumberEditText" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/textColorSubtitle1Gray</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/cerulean</item>
    <item name="colorControlNormal">@color/cerulean</item>
    <item name="colorControlActivated">@color/cerulean</item>
    <item name="android:fontFamily">@font/roboto_regular</item>
    <item name="android:textSize">12sp</item>
    <item name="android:textStyle">normal</item>
    <item name="android:lineSpacingExtra">8sp</item>
</style>

desired output picture

0 个答案:

没有答案