Change thickness of the bottom line of EditText when wrapped into TextInputLayout

前端 未结 2 1571
死守一世寂寞
死守一世寂寞 2020-12-05 03:11

here is my code

XML Markup



        
相关标签:
2条回答
  • 2020-12-05 03:36

    I've solved my issue using my custom xml drawable. There might be some better way, but I couldn't find any. following is my drawable that I'm using as background of my textbox

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true">
            <layer-list >
                <item
                    android:bottom="1dp"
                    android:left="-2dp"
                    android:right="-2dp"
                    android:top="-2dp">
                    <shape android:shape="rectangle" >
                        <stroke
                            android:width="0.5dp"
                            android:color="@color/primaryColor" />
    
                        <solid android:color="#00FFFFFF" />
    
                        <padding android:left="3dp"
                            android:right="3dp"
                            android:top="3dp"
                            android:bottom="3dp" />
                    </shape>
                </item>
    
            </layer-list>
        </item>
        <item android:state_focused="true">
            <layer-list >
                <item
                    android:bottom="1dp"
                    android:left="-2dp"
                    android:right="-2dp"
                    android:top="-2dp">
                    <shape android:shape="rectangle" >
                        <stroke
                            android:width="0.5dp"
                            android:color="@color/primaryColor" />
    
                        <solid android:color="#00FFFFFF" />
    
                        <padding android:left="3dp"
                            android:right="3dp"
                            android:top="3dp"
                            android:bottom="3dp" />
                    </shape>
                </item>
    
            </layer-list>
        </item>
        <item>
            <layer-list >
                <item
                    android:bottom="1dp"
                    android:left="-2dp"
                    android:right="-2dp"
                    android:top="-2dp">
                    <shape android:shape="rectangle" >
                        <stroke
                            android:width="0.5dp"
                            android:color="#BCBCBC" />
    
                        <solid android:color="#00FFFFFF" />
    
                        <padding android:left="3dp"
                            android:right="3dp"
                            android:top="3dp"
                            android:bottom="3dp" />
                    </shape>
                </item>
    
            </layer-list>
        </item>
    
    </selector>
    
    0 讨论(0)
  • 2020-12-05 03:40

    Edittext bottom color

    android:backgroundTint="@color/yourcolor"
    

    To disable spellchecker add code in your Edittext xml

    android:inputType="textNoSuggestions"
    

    Create an XML file with the name "EditTextStyle.xml" in the drawable folder in your project and write the following code:

    <?xml version="1.0" encoding="utf-8" ?>
    
       <shape xmlns:android="http://schemas.android.com/apk/r..."
       android:thickness="0dp"
       android:shape="rectangle">
      <stroke android:width="3dp"
         android:color="#4799E8"/>
      <corners android:radius="5dp" />
      <gradient
      android:startColor="#C8C8C8"
      android:endColor="#FFFFFF"
      android:type="linear"
      android:angle="270"/>
      </shape>
    

    Now add the following attribute to your EditText:

           <EditText    
    
            android:background="@drawable/EditTextStyle"/>
    
    0 讨论(0)
提交回复
热议问题