方法1

将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,在设置background为@null

接下来就是一个空空的edittext了, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip看看。

如果可以了就采纳吧。不行的话我再看

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/darker_gray" >
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@android:color/white"
        android:orientation="vertical" >
 
        <EditText
            style="?android:attr/textViewStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:hint="输入用户名"
            android:paddingBottom="5dip"
            android:paddingTop="5dip" />
 
        <View
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:background="@android:color/darker_gray" />
 
        <EditText
            style="?android:attr/textViewStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:hint="输入密码"
            android:inputType="textPassword"
            android:paddingBottom="5dip"
            android:paddingTop="5dip" />
    </LinearLayout>
 
</RelativeLayout>

效果图:

方法2:

自定义android控件EditText边框背景

柳志超博客 » Program » Andriod » 自定义android控件EditText边框背景

posted in Andriod on 2011/06/02 by liuzc

在我们进行Android应用界面设计和时候,为了界面风格的统一,我们需要对一些控件进行自定义。比如我们的应用采用的蓝色风格,但是android的EditText控制获得焦点后显示的却是黄色的边框背景。那么如何让EditText在获得焦点的时候显示的是我们自定义的蓝色的背景呢?

首先准备两张图片,一张是EditText获得焦点后的边框背景,一张是没有获得焦点时的背景,注意制作成9.png样式的图片,然后在drawable里添加一个selector_edittext_bg.xml文件,内容如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/edit_pressed" android:state_focused="true"/>
<item android:drawable="@drawable/edit_normal"/> </selector>

然后在values文件夹下新建一个style.xml文件,内容如下:

<?xml version="1.0" encoding="utf-8"?>
<resources> <style name="my_edittext_style" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/selector_edittext_bg</item>
</style> </resources>

最后在EditTex上使用我们新建的样式就可以了:

<EditText
android:id="@+id/v_value"
style="@style/my_edittext_style"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/edit_key"
android:imeOptions="actionDone"
android:inputType="" />

方法3

是重写的onDraw()方法

关于android中EditText边框的问题 下划线的更多相关文章

  1. Android 去除EditText边框,添加下划线,

    首先:重写EditText //请在这里添加您的包名 import android.content.Context; import android.graphics.Canvas; import an ...

  2. Android--去除EditText边框,加入下划线

    <span style="font-family: Arial, Helvetica, sans-serif;"><?xml version="1.0& ...

  3. 【我的Android进阶之旅】如何隐藏Android中EditText控件的默认下划线

    Android EditText控件是经常使用的控件,但是有时候我们并不需要它的一些默认的属性,比如说下划线,因为有时候这样的默认下划线看起来特别怪异,和其他控件在一起搭配的时候不协调,因此有时候就需 ...

  4. Android中EditText显示明文与密文的两种方式

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 记录输入框显示.隐藏密码的简单布局以及实现方式. 效果图    代码分析 方式一 /**方式一:*/ private void sh ...

  5. 【整理】Android中EditText中的InputType类型含义与如何定义( 转 )

    转自:[整理]Android中EditText中的InputType类型含义与如何定义 用到的时候查到了这篇文章觉得很不错,就在此记录下. [背景] 经过一些Android中EditText方面的折腾 ...

  6. 【转】Android中EditText中的InputType类型含义与如何定义

    原文网址:http://www.crifan.com/summary_android_edittext_inputtype_values_and_meaning_definition/ 经过一些And ...

  7. Springboot 之 自定义配置文件及读取配置文件注意:配置文件中的字符串不要有下划线 .配置中 key不能带下划线,value可以(下划线的坑,坑了我两天..特此纪念)

    注意:配置文件中的字符串不要有下划线 .配置中  key不能带下划线,value可以 错误的.不能读取的例子: mySet .ABAP_AS_POOLED      =  ABAP_AS_WITH_P ...

  8. PHP接收表单(GET/POST)时,表单名中的点变成了下划线怎么办?

    如果开发中发现,从表单中传递上来的表单名称后端接不到值,不要惊慌,很有可能是表单名称中带有特殊字符(.和空格) PHP接收参数时,发现表单名中如果是 句号(.)或者空格( ),会被转换成下划线(_) ...

  9. xml中单词下面有提示下划线

    xml中单词下面有提示下划线,表示单词拼写错误或者大小写错误

随机推荐

  1. K Best(最大化平均数)_二分搜索

    Description Demy has n jewels. Each of her jewels has some value vi and weight wi. Since her husband ...

  2. C#操作指针

    如何:递增和递减指针 使用增量和减量运算符 ++ 和 -- 可以将 pointer-type* 类型的指针的位置改变 sizeof (pointer-type). 增量和减量表达式的形式如下: ++p ...

  3. C#基础指针类型

    在C#的不安全的代码书写中,类型可以是指针类型.值类型或引用类型. 指针类型声明具有下列形式之一:   type* identifier; void* identifier; //allowed bu ...

  4. NGUI悬浮菜单思路实践

    使用NGUI制作悬浮菜单.在UIAnchor锚点下的Offset建立背景和按钮菜单.同过InputMouseXY的位置判断.是否应该弹出和收回.OffSet在此处是作为TweenGameObject的 ...

  5. [DP]数位DP总结

     数位DP总结 By Wine93 2013.7 1.学习链接 [数位DP] Step by Step   http://blog.csdn.net/dslovemz/article/details/ ...

  6. 第二个Sprint冲刺第五天

    讨论地点:qq 讨论成员:邵家文.李新.朱浩龙.陈俊金 今天工作:测试了数据的传输,总共用了三个方案,其中两个失败了,一个成功了. 开发感悟:今天吃完饭就赶着发博客了,最近有几个朋友令我特别的烦,翻脸 ...

  7. 【转】oracle job相关内容

    每天凌晨2点执行是这样的 dbms_job.submit(v_job,'lv;',TRUNC(sysdate+1)+2/24,'TRUNC(sysdate+1)+2/24'); 还有定义JOB最好是这 ...

  8. 【题解】【直方图】【Leetcode】Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  9. VS2012 编译 Assimp

    VS2012 编译 Assimp 环境: assimp-3.1.1Windows 7 64BitVisual Studio 2012CMake 2.8.12.1 注意: 在Windows中编译assi ...

  10. ZOJ 1074 To the Max

    原题链接 题目大意:这是一道好题.在<算法导论>这本书里面,有一节是介绍如何求最大子序列的.这道题有点类似,区别是从数组变成了矩阵,求最大子矩阵. 解法:完全没有算法功底的人当然不知道最大 ...