Android 更改编辑文本边框颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11485595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change edittext border color
提问by Eli Revah
I would like to know how to change the border color of the EditText view in android to something else...
我想知道如何将 android 中 EditText 视图的边框颜色更改为其他颜色...
This is my edittext view:
这是我的编辑文本视图:
<EditText
android:
android:id="@+id/codeEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btnEqual"
android:layout_marginTop="20dp"
android:ems="10"
android:gravity="top|left"
android:inputType="textMultiLine|textNoSuggestions"
android:scrollbars="vertical"
android:singleLine="false" >
Thanx upfront.
谢谢提前。
回答by oznus
There is a great Widget generator that could do all the job for you, it worked great for me.
有一个很棒的 Widget 生成器可以为您完成所有工作,对我来说效果很好。
You just have to pick your color and which widget you want (EditText for example) then you will get a xml file in the drawable directory, you should set this xml as the background of your Widget and your Done!
你只需要选择你的颜色和你想要的小部件(例如 EditText)然后你会在 drawable 目录中得到一个 xml 文件,你应该将此 xml 设置为你的小部件的背景和你的完成!
回答by eyal-lezmy
You have to override the onDraw function to do it. And you will be able to do it in one line. Here is a good example on this presentationat slide 66.
您必须覆盖 onDraw 函数才能做到这一点。而且您将能够在一行中完成。这是幻灯片 66 中有关此演示文稿的一个很好的示例。