2016-11-02 6 views
0

Ich verwende das folgende Layout. Im Grunde hat es eine benutzerdefinierte Symbolleiste, eine Navigationsleiste, ein Menü, eine ListView (listView1) und adlay.ListView fällt nach unten

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/background"> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:background="@color/header_bg" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/toolbar"> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <ListView 
      android:id="@+id/listView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="start" 
      android:layout_above="@+id/adlay" 
      android:layout_margin="7dp" 
      android:cacheColorHint="#00000000" 
      android:divider="@android:color/transparent" 
      android:dividerHeight="3dp"> 
     </ListView> 
     <LinearLayout 
      android:id="@+id/adlay" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:orientation="vertical" > 
     </LinearLayout> 
    </RelativeLayout> 

    <ListView 
     android:id="@+id/drawer_list" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="#eee" 
     android:dividerHeight="1dp" 
     android:background="#fff" 
     android:layout_below="@+id/toolbar" 
     > 
    </ListView> 
</android.support.v4.widget.DrawerLayout> 
</RelativeLayout> 

Das Layout ist ein bisschen wie die folgende Reihenfolge:

  1. Toolbar (mit Navigationsleiste und Menü)
  2. ListView1
  3. adlay

ListView1 besteht aus einer Liste von Elementen, die aus externen XML-Dateien geladen werden.

Problem ist das. Wenn listView1's Elemente nicht viel sind, dann fällt es nach unten, sitzt über adlay und es gibt eine Lücke über listView1 zwischen der Symbolleiste und listView1. Das Display ist wie folgt aus:

  1. Toolbar (mit Navigationsleiste und Menü)
  2. GAP! < --- Ich will nicht, dass die Lücke hier ist!
  3. ListView1
  4. Adlay

Dies ist nicht erwünscht Anzeige.

Idealerweise möchte ich folgendes:

  1. Toolbar (mit Navigationsleiste und Menü)
  2. ListView1
  3. GAP sollte hier sein
  4. adlay

Jede Hilfe viel ist geschätzt. Vielen Dank.

+0

Können Sie einen Screenshot des Problems hinzufügen? – motis10

+0

Danke für die Antwort. Aber ich habe das Problem behoben, alles in meinem Layout wie oben beibehalten, aber nur die layout_height von listView1 zu match_parent geändert. – Dopinder

Antwort

0

ich werde eine Layout-Datei für Ihre Anforderung schreiben. ich hoffe, dass es nützlich ist

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@android:color/white"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:background="@android:color/black" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 

     <android.support.v4.widget.DrawerLayout 
      android:id="@+id/drawer_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/toolbar"> 

      <LinearLayout 
       android:id="@+id/content_frame" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

       <ListView 
        android:id="@+id/listView1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="start" 
        android:layout_weight="1" 
        android:cacheColorHint="#00000000" 
        android:divider="@android:color/transparent" 
        android:dividerHeight="3dp"> 
       </ListView> 

       <LinearLayout 
        android:id="@+id/adlay" 
        android:layout_marginTop="10dp" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="Your Adlay Layout"/> 
       </LinearLayout> 
      </LinearLayout> 

      <ListView 
       android:id="@+id/drawer_list" 
       android:layout_width="240dp" 
       android:layout_height="match_parent" 
       android:layout_below="@+id/toolbar" 
       android:layout_gravity="start" 
       android:background="#fff" 
       android:choiceMode="singleChoice" 
       android:divider="#eee" 
       android:dividerHeight="1dp"> 
      </ListView> 
     </android.support.v4.widget.DrawerLayout> 
    </RelativeLayout> 
+0

Danke für die Antwort. Aber ich habe mein Problem behoben, mein Layout beibehalten, aber nur die layout_height von listView1 auf match_parent geändert. – Dopinder

Verwandte Themen