change the look of Edit Text box in android

落爺英雄遲暮 提交于 2019-11-27 20:51:53
learn_andrd

Try .

You can do something like this to make a rounded edit box:

Make styyles.xml in values folder.

<solid android:color="#FFFFFF"/>

<stroke
    android:width="2dp"
    android:color="#E7E7E7"
    android:height="10dp"/>

<corners
    android:radius="5dp"/>

You can then use it in xml like :

<EditBox

    style="@style/Edit_box_background"
    other attributes....
    />

Just to make the comments above a bit clearer:

You should create a file in drawables. e.g: textinputborder.xml..

Then add the following code for the border shape and color to that file:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00000000" />    
<stroke android:width="2.5dp" 
    android:color="#FFFFFF" />
<corners
android:radius="5dp"/>
</shape>     

Then use this shape for the edit text widget inside an activity xml file as required:

<EditText
     android:id="@+id/searchBox"        
     android:layout_width="fill_parent"
     android:layout_height="45dp"
     android:background="@drawable/textinputborder"
     android:hint="@string/Search"
     android:paddingLeft="10dp"
     android:inputType="textVisiblePassword" >

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