Android 安卓:开发类似Facebook的登录屏幕

Android 安卓:开发类似Facebook的登录屏幕,android,facebook,layout,Android,Facebook,Layout,我正在尝试在我的android应用程序上开发一个屏幕,比如facebook登录(应用程序iPhone/android) 如何在电子邮件和密码这两个编辑文本之间划出这条分隔线 谢谢 如果您希望在视图之间划一条线,这将有所帮助 <View android:layout_width="fill_parent" android:layout_height="2dip" android:background="#FF909090" />

我正在尝试在我的android应用程序上开发一个屏幕,比如facebook登录(应用程序iPhone/android)

如何在电子邮件和密码这两个编辑文本之间划出这条分隔线


谢谢

如果您希望在视图之间划一条线,这将有所帮助

<View
         android:layout_width="fill_parent"
         android:layout_height="2dip"
         android:background="#FF909090" />


如果您希望自定义EditText,这些链接可能会对您有所帮助。

要实现这样的效果,您只需使自己的9-patch可绘制即可。我已经在我的应用程序上做过这样的事情了,看到了吗

布局顶部可拉伸非冲压

顶部可拉深冲压布局

布局底部可拉深非冲压

布局底部可拉深冲压

剩下的唯一一件事是构建两个选择器,一个用于顶部编辑文本,另一个用于底部edittext,并将它们设置为edittext的backround:

选择器_top_editText.xml:

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

    <item android:drawable="@drawable/layout_top_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/layout_top_normal"/>

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

    <item android:drawable="@drawable/layout_bottom_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/layout_bottom_normal"/>

</selector>

选择器_bottom_editText.xml:

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

    <item android:drawable="@drawable/layout_top_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/layout_top_normal"/>

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

    <item android:drawable="@drawable/layout_bottom_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/layout_bottom_normal"/>

</selector>

对于您的登录页面,您可以使用此布局

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


        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:ems="10"
            android:inputType="textPersonName"
            android:background="@drawable/layout_top_selector" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:ems="10"
            android:inputType="textPassword" 
            android:background="@drawable/layout_bottom_selector"
            android:layout_below="@id/editText1"/>

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="46dp"
            android:text="Login" />

</RelativeLayout>

检查此项,如果发现问题,请与我保持联系


干杯!我在两个编辑文本之间添加了这个视图,但它很难看!这是一个线性布局,添加了:1)编辑文本2)此视图3)编辑文本屏幕截图:这是在Android中绘制水平线的方式,您可以根据需要更改它的颜色(Android:background)、厚度(Android:layout\u height)和宽度(Android:layout\u width)。如果您正在查看Facebook登录的确切外观,然后你需要有一个自定义的EditText类。是的,但是,我不能在EditText上“粘住”一行,它们之间总是有一个空格。我已经编辑了答案,给了你两个选项,现在你需要自己解决。背景上有透明的EditText怎么样?嘿!谢谢你的帮助。看看边框,为什么我的编辑文本是这样的?那是因为你没有使用过9-patch图像你使用的是普通的png图像你不熟悉9-patch吗?如果你不给我发电子邮件,我会给你发!!嘿,库阿纳斯,谢谢你的帮助!我想我无法在StackOverflow向您发送电子邮件:(发送的电子邮件请让我知道它是否完全符合您的需要。