开发者社区> 问答> 正文

关于android中EditText边框的问题报错 

请教各位大大,新浪微博android客户端,在登录界面的输入框中,账号输入框与密码输入框之间的灰色边框是如何实现的呢?
如下图所示:

在线等。

展开
收起
kun坤 2020-06-03 09:39:15 637 0
1 条回答
写回答
取消 提交回答
  • 引用来自“亓斌哥哥”的评论

    将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,在设置background为 @null 接下来就是一个空空的edittext了, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip看看。 如果可以了就采纳吧。不行的话我再看

    引用来自“亓斌哥哥”的评论

    <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>
    效果图: ######非常感谢你的回答,刚才我用另外一种方法也实现出了同样的效果。是重写的onDraw()方法。你提供的这个方法我也去试试。######可能是设定的背景图片###### 将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,在设置background为 @null 接下来就是一个空空的edittext了, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip看看。 如果可以了就采纳吧。不行的话我再看 ######

    引用来自“亓斌哥哥”的评论

    将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,在设置background为 @null 接下来就是一个空空的edittext了, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip看看。 如果可以了就采纳吧。不行的话我再看
    <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>
    ######用你这个方法的话,那要控制那条黑线的长短只能通过设置view的width属性来实现吧?
    2020-06-03 09:39:24
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载