To remove the underline from an EditText in Android, you can achieve this by modifying the XML layout or programmatically using Java or Kotlin.
In your XML layout file, set the background attribute of the EditText to either a transparent background or null, like so:
<EditText android:id="@+id/myEditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@null" android:hint="Hint Anda Di Sini"/>
This method can also solve issues such as:
How do I hide the underline of an EditText (the quick line with small serifs at the end)?
You may want a more refined way to achieve what you need. Let's say you have a layout with an EditText that typically displays nicely, where users can tap to start entering or editing text.
However, sometimes you want to use the same layout (to simplify other logic) to display the same data in a read-only manner. The presentation should be similar—maintaining the same height and font size—but without the underline.
As a temporary workaround, you might consider replacing the EditText with a TextView. This could achieve the desired appearance, but it may seem like an expensive solution for something that should ideally be simple to do by toggling an attribute.