2016-12-02 2 views
0

У меня есть макет под названием «status2.xml», и его код размещен ниже. и у меня есть основной макет под названием «meine_vertaege.xml», и его код также размещен ниже. «act_main.xml» включает в себя вышеупомянутые макеты, , которые являются «status2.xml» и «meine_vertaege.xml».как включить два отдельных макета в один макет

Я включаю «status2.xml» и «meine_vertaege» в «act_main.xml», как показано ниже в коде «act_main.xml».

проблема у меня есть, когда я включаю оба «status2.xml» и meine_vertaege »в« act_main.xml », я не могу увидеть все содержимое« status2.xml », потому что кажется, что содержимое «status2.xml» и «meine_vertaege.xml» смешалось

пожалуйста, дайте мне знать, как включить оба «status2.xml» и «meine_vertaege» в «act_main.xml», так что я могу видеть их цельные содержание таким образом, что они организованы вертикально

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> 

выход status2.xml:

enter image description here

meine_vertaege.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_vertaege.xml:

enter image description here

act_main.xml:

<?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:

enter image description here

+0

попробуйте поместить эти 2 макета в scrollview и установить вес для этих 2 макетов в act_main.xml? – Raghavendra

ответ

5

Попробуйте, как это.

<?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> 
Смежные вопросы