Android Development: How Can I Make An EditText Plain So It's Just A White Square?

徘徊边缘 提交于 2019-12-01 02:15:04

问题


As the title says, I've seen EditTexts where they are just plain white with no smooth corners or orange android border when you highlight it etc.

Like it looks in this app: http://s1.appbrain.com/screen?id=-2631427781674403509&i=1


回答1:


You need to create a custom background 9-patch image like this one and put it to /res/drawable directory. Here is the tutorial for 9-patch images. Then you need to apply the image as a background for your EditText using android:background attribute.

Here is a sample layout xml:

<EditText
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:background="@drawable/white_bg"
    android:text="Test"
    android:layout_marginBottom="5dip" /> 

<EditText
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:background="@drawable/white_bg"
    android:text="Currently focused" />

And here is the result:



来源:https://stackoverflow.com/questions/4353265/android-development-how-can-i-make-an-edittext-plain-so-its-just-a-white-squar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!