安卓EditText默认样式

3
我需要展示一个EditText,使用经典布局显示完整的文本框,而不仅仅是底部的线。在布局编辑器中,我可以看到它是这样的,但是当运行应用程序时,它只显示底部的线条。我正在使用android:Theme.Light的应用程序主题。我该如何更改呢?
这是我想要的: enter image description here 这是我看到的: enter image description here

EditText只是一个9patch图像,所以您只需要更改图像以使其看起来像您想要的样子。 - tyczj
3个回答

2

//你可以尝试这个,它对我有效

<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>

0

尝试使用这个解决方案

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

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

0

你可以将一个图像框作为可绘制对象导入,然后像这样将其设置为背景。

<EditText
    android:id="@+id/textinput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/imagebox"/>

这样做后,图像框将放置在文本框下方,下划线也会消失。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接