水平线登录页面

问题描述 投票:1回答:6

你好,我想设计类似这样的一个登录页面。问题是,每当我添加了查看标签来创建一个水平线,并对齐“或”字。如在这张照片它不达到同样的效果。相反,它赞同 - alignBottomLine。

Horizontal line

android android-studio android-relativelayout
6个回答
4
投票

用这个:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">
<View
    android:layout_height="2dp"
    android:layout_width="50dp"
    android:background="#000"
    android:layout_gravity="center"/>

<TextView
    android:layout_marginStart="10dp"
    android:layout_marginEnd="10dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="or"
    android:layout_gravity="center"/>

<View
    android:layout_height="2dp"
    android:layout_width="50dp"
    android:background="#000"
    android:layout_gravity="center"/>
</LinearLayout>

您可以更改layout_widthView设置线的大小,颜色等。

这是输出:

enter image description here


0
投票

试试这个那个特定部分

<LinearLayout
 android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:gravity="center"
  android:orientation="horizontal">

      <View
       android:layout_width="200dp"
       android:layout_height="1dp"
       android:background="#c4c8c9"
       android:layout_margin="5dp" />

      <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:padding="5dp"
       android:text="or"
       />

       <View
       android:layout_width="200dp"
       android:layout_height="1dp"
       android:background="#c4c8c9"
       android:layout_margin="5dp" />

 </LinearLayout>

0
投票

试试这个方式,它为我工作

<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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        >

        <View
            android:layout_width="50dp"
            android:layout_height="1dp"
            android:background="@android:color/holo_red_dark"
            android:layout_gravity="center_vertical"
            />
    <TextView android:text="Or" android:layout_width="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_height="wrap_content" />

        <View
            android:layout_width="50dp"
            android:layout_height="1dp"
            android:background="@android:color/holo_red_dark"
            android:layout_gravity="center_vertical"
            />
    </LinearLayout>
</RelativeLayout>

0
投票
         <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/forgot_password"
              >

            <View
                android:layout_width="fill_parent"
                android:layout_height="0.75dp"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/tv_1"
                android:layout_marginLeft="50dp"
                android:background="#cecece" />

            <TextView
                android:id="@+id/tv_1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:text="OR"
                android:textColor="#696969"
                android:textSize="13sp" />

            <View

                android:layout_width="fill_parent"
                android:layout_height="0.75dp"
                android:layout_marginRight="50dp"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@+id/tv_1"
                android:background="#cecece" />
        </RelativeLayout>

我希望它会很有用


0
投票

您可以使用此单的TextView做工精细

<TextView
     android:drawablePadding="10dp"
     android:drawableLeft="@drawable/seprator_line.png"
     android:drawableRight="@drawable/seprator_line.png"/>

我希望这帮助。


-1
投票

下面是我会做,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E73A4A">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_margin="16dp">

    <View
        android:layout_width="200dp"
        android:layout_height="2dp"
        android:layout_centerInParent="true"
        android:background="#F6828F" />

    <TextView
        android:layout_width="30dp"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#E73A4A"
        android:text="or"
        android:textAlignment="center"
        android:textColor="#F6828F" />
</RelativeLayout>

© www.soinside.com 2019 - 2024. All rights reserved.