更改的EditText边框颜色边框、颜色、EditText

由网友(零)分享简介:我想知道如何改变的EditText视图的边框颜色在Android中别的东西...... I would like to know how to change the border color of the EditText view in android to something else...这是我的EditTe...

我想知道如何改变的EditText视图的边框颜色在Android中别的东西......

I would like to know how to change the border color of the EditText view in android to something else...

这是我的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.

推荐答案

您必须创建/修改自己的NinePatch形象,以取代默认的,并使用它作为您的EditText的背景。如果你看看你的SDK文件夹,你的平台下,然后RES /绘制,你应该找到NinePatch形象为重点的EditText状态。如果这是你想改​​变,你可以把它导入到Photoshop,或任何图像编辑软件,你最喜欢的,并改变橙色到你所选择的颜色。然后保存到你的绘制文件夹,并建立一个新的StateListDrawable,例如,像下面的:

You'll have to create/modify your own NinePatch image to replace the default one, and use that as the background of your EditText. If you look in your SDK folder, under your platform, then res/drawable, you should find the NinePatch image for the EditText focus state. If that's all you want to change, you can just pull it into Photoshop, or whatever image editing software you like best, and change the orange color to a color of your choosing. Then save that into your drawable folder, and build a new StateListDrawable, for example something like the below:

<?xml version="1.0" encoding="utf-8"?>
<selector 
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <item 
        android:state_pressed="true"
        android:drawable="@android:drawable/edittext_pressed" 
        /> <!-- pressed -->    
    <item 
        android:state_focused="true"
        android:drawable="@drawable/edittext_focused_blue" 
        /> <!-- focused -->    
    <item 
        android:drawable="@android:drawable/edittext_normal" 
        /> <!-- default -->
</selector>

我不知道随便的实际名称为默认NinePatches的EditText上,所以那些在必要时更换,但这里的关键是只使用了 @android:绘制图像,没有修改的那些(或者您可以通过将它们复制到项目的绘制文件夹),然后用修改后的绘制你的聚焦状态。

I don't know offhand the actual names for the default NinePatches for the EditText, so replace those as necessary, but the key here is to just use the @android:drawable images for the ones you haven't modified (or you can copy them over to your project's drawable folder), and then use your modified drawable for your focused state.

您可以再设置这个StateListDrawable为背景为您的TextView,像这样:

You can then set this StateListDrawable as the background for your TextView, like so:

<TextView
    android:background="@drawable/edittext_modified_states"

在某些操作系统版本,您可能还需要正常未修改的状态的照片复制到应用程序文件夹绘制得到这个工作。因此,在您的应用程序的绘制文件夹你有修改的焦点状态的画面,也未经修改的原始缔约国另一方的照片也是如此。

On some OS versions, you might also have to copy the normal unmodified state pictures into the applications drawable folder to get this work. So in your application's drawable folders you have the modified focus state picture and also unmodified original other state pictures as well.

阅读全文

相关推荐

最新文章