'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:
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>
Solution 1:[1]
You can just change the size of your image. For example, icon with size 48x48dp is twice as large as 24x24dp, look at the screenshots. (It also works with non-vector images)
Solution 2:[2]
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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | OwlCodR |
Solution 2 | Drioueche Mohammed |