본문 바로가기
Android

[Android] EditText 내부의 밑줄 제거하기

by 워뇨옹2 2021. 10. 18.
728x90
반응형

Layout

먼저 layout 파일로 들어간 다음, 밑줄을 제거하고 싶은 EditText의 속성에 다음 한 줄을 추가해준다.

 

<EditText
	...
    android:background="@null"
    .../>

background에 아무것도 넣지 않음으로 밑줄도 사라지게 된다.

 

Kotlin

런타임에서 동적으로 나타나게하거나 사라지게 하고 싶다면 다음과 같이 해준다.

val defaultBackground = binding.editText.background //밑줄이 있는 백그라운드를 따로 저장

if (case == "INVISIBLE_UNDERLINE") { 
	binding.editText.background = null
} else if (case == "VISIBLE_UNDERLINE") {
	binding.editText.background = defaultBackground
}

이런식으로 런타임에서 EditText의 밑줄을 나타내거나 사라지게 할 수 있다.

728x90
반응형