Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change startIconDrawable Size in TextInputLayout

Seems like there is no XML attribute to change the startIconDrawable size in android. The icon is oversized as compared to the text. Here is a screenshot of the issue:

enter image description here

Here is my XML:

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.google.android.material.textfield.TextInputLayout
                style="@style/textInputStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Enter Paypal ID"
                android:padding="5dp"
                app:endIconMode="clear_text"
                app:startIconDrawable="@drawable/ic_paypal_logo">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/et_form_question_hint"
                    style="@style/textInputEditext"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:paddingHorizontal="@dimen/normalPadding" />

            </com.google.android.material.textfield.TextInputLayout>
        </LinearLayout>


If anyone wishes to reproduce styles are as follows:

<style name="textInputEditext" parent="FirebaseUI.TextInputEditText">
        <item name="maxLine">1</item>
        <item name="android:textColor">@color/colorOnSurface</item>
    </style>

<style name="textInputStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
        <item name="android:layout_marginBottom">12dp</item>
        <item name="errorEnabled">true</item>
        <item name="endIconTint">@color/colorSurface</item>
        <item name="hintTextColor">@color/colorOnSurface</item>
        <item name="shapeAppearance">@style/Cut</item>
        <item name="boxStrokeColor">#AA000000</item>
        <item name="android:textColorHint">@color/colorOnSurface</item>
        <item name="android:textStyle">bold</item>
        <item name="counterTextColor">@color/colorOnSurface</item>
        <item name="android:textColor">@color/colorOnSurface</item>
    </style>

like image 347
AmanSharma Avatar asked Sep 20 '25 00:09

AmanSharma


1 Answers

There is no attribute to edit drawable size (until now).

However if you use the icon in many places in your code and you don't wanna mess with you original icon size, you can wrap it in an other drawable and change the item size there.

Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:width="24dp" android:height="24dp"
        android:drawable="@drawable/ic_yourIconName" />
</layer-list>
like image 89
Drioueche Mohammed Avatar answered Sep 21 '25 14:09

Drioueche Mohammed