• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: How to remove padding for the bottom line of the TextInputEditText

Resolved: How to remove padding for the bottom line of the TextInputEditText

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I’m trying to remove all padding of a TextInputLayout and a TextInputEditText, but with padding=0dp the line at the bottom of the TextInputEditText keeps it padding left and right. How I can remove this padding?
This is the xml code that I’ve used.
The styles are:
View
Thank you

Answer:

You can use your own custom style for TextInputLayout as below:
  1. Your layout:

    <com.google.android.material.textfield.TextInputLayout
            ....
            android:hint="Your hint text"       
            style="@style/My.TextInputLayout.Theme" >
    
  2. Then define your custom theme as below:

     <style name="My.TextInputLayout.Theme" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
         <item name="materialThemeOverlay">@style/MyThemePadding</item>
       </style>
    
       <style name="MyThemePadding">
         <item name="editTextStyle">@style/MyTextInputEditText_padding</item>
       </style>
    
       <style name="MyTextInputEditText_padding" parent="@style/Widget.MaterialComponents.TextInputEditText.FilledBox">
         <!-- Set left and right padding here -->
         <item name="android:paddingStart" ns2:ignore="NewApi">2dp</item>
         <item name="android:paddingEnd" ns2:ignore="NewApi">2dp</item>
         <item name="android:paddingLeft">2dp</item>
         <item name="android:paddingRight">2dp</item>
    
         <!-- Set top and bottom padding here -->
         <item name="android:paddingTop">28dp</item>
         <item name="android:paddingBottom">12dp</item>
       </style>
    

If you have better answer, please add a comment about this, thank you!

android android-edittext android-textinputedittext android-textinputlayout
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Kivy widget hierarchy not behaving as expected

24/03/2023

Resolved: Pandas Groupby Get Values from Previous Group

24/03/2023

Resolved: Can’t access static methods from outside until JavaScript’s static block is over?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.