Al *_*aba 6 android android-layout
如何删除android中的Edittext字段的边框.实际上它看起来像这样
有了这个布局代码
<EditText
android:id="@+id/login_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:background="@android:drawable/editbox_background_normal"
android:visibility="invisible"
android:textColor="#FF0000"
android:layout_gravity="right"
/>
Run Code Online (Sandbox Code Playgroud)
尽管我定义了文本,但文本的对齐方式并不在右侧.
谢谢
ast*_*ter 15
简单地说,您可以在xml
文件中使用以下内容以使EditText
背景清晰:
android:background="@null"
Run Code Online (Sandbox Code Playgroud)
程序化方法:
setBackgroundDrawable(null);
Run Code Online (Sandbox Code Playgroud)
或者,因为在API 16中对setBackgroundDrawable()进行了删除:
if (Build.VERSION.SDK_INT >= 16)
setBackground(null);
else
setBackgroundDrawable(null);
Run Code Online (Sandbox Code Playgroud)
您可以EditText
使用以下xml布局自定义您的
将以下代码保存为yourWishName.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
//You can change the color of the edit text here which removes the border line as well
<item android:state_focused="true" >
<shape android:shape="rectangle">
<gradient
android:startColor="#FFFFFF"
android:endColor="#FFFFFF"
android:angle="270" />
<stroke
android:width="3dp"
android:color="#F8B334" />
<corners
android:radius="12dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#FFFFFF"
android:endColor="#FFFFFF"
android:angle="270" />
<stroke
android:width="0dp"
android:color="#000000" />
<corners
android:radius="12dp" />
</shape>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
在EditText中调用xml android:background="@drawable/yourWishName"
对齐正确使用 android:gravity="right"
希望这可以帮助