Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在线性布局中对齐_Android - Fatal编程技术网

Android 在线性布局中对齐

Android 在线性布局中对齐,android,Android,我使用线性布局。我必须做到: 我试过这样的方法: <View android:layout_width="88dp" android:layout_height="0.25dp" android:layout_marginLeft="43dp" android:layout_marginTop="26dp" android:layout_gravity="le

我使用线性布局。我必须做到:

我试过这样的方法:

<View
    android:layout_width="88dp"
    android:layout_height="0.25dp"
    android:layout_marginLeft="43dp"
    android:layout_marginTop="26dp"
    android:layout_gravity="left"
    android:background="#ffffff" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="login to app"
    android:textColor="@color/white"
    android:textSize="10sp" />
<View
    android:layout_width="88dp"
    android:layout_height="0.25dp"
    android:layout_gravity="right"
    android:layout_marginRight="43dp"
    android:background="#ffffff" />

但结果是:


如何解决此问题?

垂直居中
添加到所有
android:layout\u gravity
。例如:

android:layout_gravity="left|center_vertical"
更新#1

<LinearLayout orientation="vertical">
    <FrameLayout
        layout_width="match_parent"
        layout_height="wrap_content">

        <View
            android:layout_width="88dp"
            android:layout_height="0.25dp"
            android:layout_marginLeft="43dp"
            android:layout_marginTop="26dp"
            android:layout_gravity="left|center_vertical"
            android:background="#ffffff" />

       <TextView
           android:id="@+id/textView2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           android:text="login to app"
           android:textColor="@color/white"
           android:textSize="10sp" />

       <View
           android:layout_width="88dp"
           android:layout_height="0.25dp"
           android:layout_gravity="right|center_vertical"
           android:layout_marginRight="43dp"
           android:background="#ffffff" />        

    </FrameLayout>

    <!-- Other stuff -->

</LinearLayout>


我是这样做的:它不工作。你能给我编辑过的代码吗?@Okan它改变了这些视图的外观吗?是的,我改变了,但结果还是一样。你能给我编辑过的代码吗?我想我不太明白,就我所知,它应该起作用。你能从
TextView
中删除
center\u horizontal
并告诉我结果吗