How to hide underbar in EditText

后端 未结 25 1765
温柔的废话
温柔的废话 2020-11-28 00:52

How can I hide the EditText underbar (the prompt line with little serifs at the ends)?

There might be a better way to do what I want: I have a layout with an EditTe

相关标签:
25条回答
  • 2020-11-28 01:21

    if your edit text already has a background then you can use following.

    android:textCursorDrawable="@null"
    
    0 讨论(0)
  • 2020-11-28 01:21

    android:inputType="textVisiblePassword|textMultiLine" android:background="@android:color/transparent"

    ...its not the optimal solution but it works.

    0 讨论(0)
  • 2020-11-28 01:23

    Set background to null.

    android:background="@null"
    
    0 讨论(0)
  • 2020-11-28 01:23

    You can do it programmatically using setBackgroundResource:

    editText.setBackgroundResource(android.R.color.transparent);
    
    0 讨论(0)
  • 2020-11-28 01:24

    What I did was to create a Shape drawable and set that as the background:

    <?xml version="1.0" encoding="utf-8"?>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
    
        <padding
            android:top="8dp"
            android:bottom="8dp"
            android:left="8dp"
            android:right="8dp" />
    
        <solid android:color="#fff" />
    
    </shape>
    

    Note: I actually used @dimen and @color values for the firelds, but I've simplified the shape file here for clarity.

    0 讨论(0)
  • 2020-11-28 01:27

    You can set EditText's backgroundTint value to a specific color. If you set transparent color, underbar should gone.

    android:backgroundTint="@color/Transparent"

    <color name="Transparent">#00000000</color>

    But you can use this in Api v21(Lollipop) or higher

    0 讨论(0)
提交回复
热议问题