Issue
How to position the drawable start icon at the start of text input layout
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="New Password"
app:expandedHintEnabled="true"
app:hintTextAppearance="@style/text_medium_12_size"
app:errorTextAppearance="@style/text_regular_10_size"
app:boxStrokeColor="@color/main_theme_color"
app:startIconDrawable="@drawable/ic_baseline_lock"
style="@style/Widget.Design.TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:drawablePadding="0dp"
style="@style/text_medium_12_size"
android:importantForAutofill="no"/>
</com.google.android.material.textfield.TextInputLayout>
The result of the above code is show in image below
But I want to achieve like the drawable start icon at start of the text input layout start which is show as image attched below
I need to remove the extra start space between drawable start icon of the text input layout. Is is possible to achieve it?
Solution
remove app:startIconDrawable="@drawable/ic_baseline_lock"
in TextInputLayout
and add android:drawableStart="@mipmap/ic_baseline_lock"
in TextInputEditText
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="New Password"
app:expandedHintEnabled="true"
app:hintTextAppearance="@style/text_medium_12_size"
app:errorTextAppearance="@style/text_regular_10_size"
app:boxStrokeColor="@color/main_theme_color"
app:startIconDrawable="@drawable/ic_baseline_lock" // remove this line
style="@style/Widget.Design.TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:drawableStart="@mipmap/ic_baseline_lock" //add this line
android:drawablePadding="0dp"
style="@style/text_medium_12_size"
android:importantForAutofill="no"/>
</com.google.android.material.textfield.TextInputLayout>
Answered By - GHH
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.