Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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_Xml_Android Linearlayout_Android Relativelayout - Fatal编程技术网

Android 如何在一个布局中包含两个单独的布局

Android 如何在一个布局中包含两个单独的布局,android,xml,android-linearlayout,android-relativelayout,Android,Xml,Android Linearlayout,Android Relativelayout,我有一个名为“status2.xml”的布局,其代码发布在下面。我有一个名为“meine_Vertage.xml”的主布局,其代码也发布在下面。“act_main.xml”包括上述布局, 即“status2.xml”和“meine_vertage.xml” 我将“status2.xml”和“meine_vertage”包含在“act_main.xml”中,如下面“act_main.xml”的代码所示 我的问题是,当我在“act_main.xml”中同时包含“status2.xml”和“meine

我有一个名为“status2.xml”的布局,其代码发布在下面。我有一个名为“meine_Vertage.xml”的主布局,其代码也发布在下面。“act_main.xml”包括上述布局, 即“status2.xml”和“meine_vertage.xml”

我将“status2.xml”和“meine_vertage”包含在“act_main.xml”中,如下面“act_main.xml”的代码所示

我的问题是,当我在“act_main.xml”中同时包含“status2.xml”和“meine_vertage”时,我看不到“status2.xml”的全部内容,因为“status2.xml”和“meine_vertage.xml”的内容 搞混了

请让我知道如何在“act_main.xml”中同时包含“status2.xml”和“meine_vertage”,以便我能够以垂直组织的方式查看它们的全部内容

status2.xml

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:gravity="center_vertical"
        android:text="Status"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="3dp"
    android:layout_weight="5">

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:text="vertraege"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.example.bestandlayout_00.ActMain">

<include
    android:id="@+id/lay1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/status2"></include>

<include
    android:id="@+id/lay2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/meine_vertaege"></include>
</LinearLayout>

status2.xml的输出:

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:gravity="center_vertical"
        android:text="Status"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="3dp"
    android:layout_weight="5">

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:text="vertraege"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.example.bestandlayout_00.ActMain">

<include
    android:id="@+id/lay1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/status2"></include>

<include
    android:id="@+id/lay2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/meine_vertaege"></include>
</LinearLayout>

meine_vertage.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actMain_meine_vertraege_layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/padding">

<TextView
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@color/gray"
    android:gravity="center_vertical|start"
    android:paddingStart="@dimen/padding"
    android:text="Meine Verträge" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/actMain_lisVie"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></ListView>
</ScrollView>
</LinearLayout>

meine_vertage.xml的输出

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:gravity="center_vertical"
        android:text="Status"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="3dp"
    android:layout_weight="5">

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:text="vertraege"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.example.bestandlayout_00.ActMain">

<include
    android:id="@+id/lay1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/status2"></include>

<include
    android:id="@+id/lay2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/meine_vertaege"></include>
</LinearLayout>

act_main.xml

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:gravity="center_vertical"
        android:text="Status"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="3dp"
    android:layout_weight="5">

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:text="vertraege"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.example.bestandlayout_00.ActMain">

<include
    android:id="@+id/lay1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/status2"></include>

<include
    android:id="@+id/lay2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/meine_vertaege"></include>
</LinearLayout>

act_main.xml的输出:

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:gravity="center_vertical"
        android:text="Status"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="3dp"
    android:layout_weight="5">

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:paddingStart="10dp"
        android:text="vertraege"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.example.bestandlayout_00.ActMain">

<include
    android:id="@+id/lay1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/status2"></include>

<include
    android:id="@+id/lay2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/meine_vertaege"></include>
</LinearLayout>
像这样试试

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
            <include
                android:id="@+id/lay1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1dp"
                layout="@layout/status2"></include>

            <include
                android:id="@+id/lay2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1dp"
                layout="@layout/meine_vertaege"></include>
</LinearLayout>

像这样试试

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
            <include
                android:id="@+id/lay1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1dp"
                layout="@layout/status2"></include>

            <include
                android:id="@+id/lay2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1dp"
                layout="@layout/meine_vertaege"></include>
</LinearLayout>


尝试将这两个版面放在scrollview中,并在act_main.xml中为这两个版面设置权重?尝试将这两个版面放在scrollview中,并在act_main.xml中为这两个版面设置权重?