多彩色边框的EditText [英] Multi-colored border EditText

查看:134
本文介绍了多彩色边框的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何使有黑边沿着它的左右两侧,上面绿色边框定制的EditText,并且在底部有一个蓝色边框。见下文:

I'm trying to figure out how to make a custom EditText that has black borders along it's right and left sides, a green border on top, and a blue border on the bottom. See below:

我是相当新的Andr​​oid开发,我已经花了相当多的时间去阅读它们的文档,但还没有任何运气找到对这种自定义的东西。我知道CSS,你可以只使用右边框,左边框,等等属性,但不知道它在Android开发那么简单。我在寻找,这是最兼容,preferably从版本2.3(姜饼)的解决方案。

I'm fairly new to Android development and I've spent quite a lot of time reading their documentation but haven't had any luck finding anything on this kind of customization. I know in CSS you can just use the border-right, border-left, etc... properties but not sure if it's that straightforward in Android development. I'm looking for the solution that is the most compatible, preferably from version 2.3 (Gingerbread).

推荐答案

您将不得不作出为背景,以使用自定义图像。这是比较简单的,你要使用9补丁所描述的在2D图形指南

You'll have to make a custom image to use as the background. It's relatively straight forward, you'll want to use a 9-patch as described in the 2D graphics guide.

一旦你的,你会把它放在你的项目的RES /可绘制文件夹,然后用它与在的EditText XML作为

Once you have that, you'll put it in your res/drawable folder of your project, and then use it with the EditText in XML as

<EditText
    android:background="@drawable/my_custom_background"
    ...
/>

这篇关于多彩色边框的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆