在LinearLayout中水平堆叠两个垂直LinearLayout

时间:2016-12-17 14:34:04

标签: android android-layout xamarin.android

我试图在LinearLayout中水平堆叠两个垂直LinearLayout。 我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_margin="10dp"
        android:orientation="vertical">
        <TextView
            android:text="User Name"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/txtusername" />
        <TextView
            android:text="Date registration"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/txtdateregistr" />
        <TextView
            android:text="Phone number"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/txtphonenumb" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_margin="10dp"
        android:orientation="horisontal"
        android:minWidth="25px"
        android:minHeight="25px">
        <LinearLayout
            android:orientation="vertical"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linearLayout1">
            <TextView
                android:text="Count"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/ordercountnumb" />
            <TextView
                android:text="Ordr"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/ordercount" />
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/linearLayout1">
            <TextView
                android:text="Count"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/deliverycountnumb" />
            <TextView
                android:text="Delv"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/deliverycount" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

一切看起来都像我一样,已经构思出来:

Also everything looks as I and has conceived

以及充分理解的计划:

enter image description here

但是当我在VS2015中编译时,请看错误&#34;不允许使用字符串类型(在&#39;方向&#39;有价值&#39;水平&#39;)&#34;。需要帮助

3 个答案:

答案 0 :(得分:2)

这是一个错字。

更改,

android:orientation="horisontal"

android:orientation="horizontal"

答案 1 :(得分:0)

在root use root属性

wheightSum =&#34; 10&#34;

并且在子视图中使用wheight =&#34; 5&#34;对于每个子视图

注意:在基本布局上使用android:orientation =&#34; horizo​​ntal&#34;用于水平显示或android:orientation =&#34; vertical&#34;用于垂直显示

答案 2 :(得分:0)

LinearLayout orientation的错误。它应该是水平的或删除它。(默认线性布局具有水平方向。

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_margin="10dp"
        android:orientation="vertical">
        <TextView
            android:text="User Name"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/txtusername" />
        <TextView
            android:text="Date registration"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/txtdateregistr" />
        <TextView
            android:text="Phone number"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/txtphonenumb" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_margin="10dp"
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px">
        <LinearLayout
            android:orientation="vertical"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linearLayout1">
            <TextView
                android:text="Count"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/ordercountnumb" />
            <TextView
                android:text="Ordr"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/ordercount" />
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/linearLayout1">
            <TextView
                android:text="Count"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/deliverycountnumb" />
            <TextView
                android:text="Delv"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/deliverycount" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>