EditText attribute attribute not working for API 21 and 22

Setting the fill value for my EditTexts. However, it does not work with both 21 and 22 api versions. However, it works great 19, 23, 24.

Here are my codes :

<style name="LoginEditTextStyle">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_gravity">center_horizontal</item>
        <item name="android:maxLines">1</item>
        <item name="android:paddingLeft">@dimen/login_text_padding</item>
        <item name="android:paddingRight">@dimen/login_text_padding</item>
    </style>

This is my edittext in xml layout

<android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
          android:layout_marginTop="@dimen/login_container_child_view_top_margin"
            android:alpha="0">

            <EditText
                android:id="@+id/login_username_editText"
                style="@style/LoginEditTextStyle"
                android:hint="@string/user_name"
                android:inputType="text"
                />

        </android.support.design.widget.TextInputLayout>

Result for version 21 api

enter image description here

for version 24 api

enter image description here

I know that there is an edittext / spinner error parameter for setting padding value from xml.

I know that there is some solution for this problem, for example, setting strip values ​​programmatically. But this does not work for me.

for example: this decision doesn't work for me

int paddingLeft = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, getResources().getDisplayMetrics());
        int paddingRight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 55, getResources().getDisplayMetrics());
        int paddingTop = editText.getPaddingTop();
        int paddingBottom = editText.getPaddingBottom();
        editText.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
+4
source share
1

. paddingLeft Android 5.1.1.

paddingStart , .

, .

0

Source: https://habr.com/ru/post/1677671/


All Articles