自定义设计 EditText [英] Custom designing EditText

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

问题描述

我有定制设计的EditText

search_page.xml

</LinearLayout>

rounded_edittext.xml

<solid android:color="#FFFFFF"/><角落机器人:bottomLeftRadius =10dp"机器人:bottomRightRadius =10dp"机器人:topLeftRadius =10dp"android:topRightRadius="10dp"/></形状>

<小时>

我想使用颜色代码 #2f6699 将边框颜色像轮廓一样添加到 EditText 文本框,如下所示:

关于如何实现这一目标的任何想法?

解决方案

在您的 rounded_edittext.xml

中使用以下代码

这应该有效

I have custom designed EditText

search_page.xml

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="10dp"
    android:background="#E1E1E1"
    android:weightSum="1" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".25"
        android:text="City" />

    <EditText
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:background="@drawable/rounded_edittext"
        android:layout_weight=".75" />
</LinearLayout>

rounded_edittext.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle" >

    <solid android:color="#FFFFFF" />

    <corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />

</shape>


I want to use color code #2f6699 to get a border color like an outline to the EditText text box as below:

Any ideas on how to achieve this?

解决方案

Use the below code in your rounded_edittext.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <solid android:color="#FFFFFF" />

    <stroke
        android:width="1dp"
        android:color="#2f6699" />
    <corners 
        android:radius="10dp"            
        />

</shape>

This should work

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

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