How to hide underbar in EditText

后端 未结 25 2097
温柔的废话
温柔的废话 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:20

    An other option, you can create your own custom EditText like this :

    class CustomEditText : androidx.appcompat.widget.AppCompatEditText {
        constructor(context: Context?) : super(context)
        constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
        constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
    
        private val paint = Paint()
        private val path = Path()
    
        init { // hide your underbar
            this.setBackgroundResource(android.R.color.transparent)
    
            // other init stuff...
        }
    
        override fun onDraw(canvas: Canvas?) {
            super.onDraw(canvas)
    
            // draw your canvas...
        }
    }
    

提交回复
热议问题