2016-11-02 21 views
0

私は次のレイアウトを使用しています。基本的には、カスタムツールバー、ナビゲーションドロワー、メニュー、ListView(listView1)、およびadlayがあります。ListViewが下に降ります

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

レイアウトは一種の次の順序のようなものです:ListView1のリストで構成されています(ナビゲーション引き出して、メニュー付き)

  1. ツールバー
  2. ListView1の
  3. ハトムギ

外部XMLファイルからロードされた項目の数。

問題はこれです。 listView1の項目がそれほど多くない場合は、下に落ちて、広告の上に座っていて、ツールバーとlistView1の間にlistView1の上にギャップがあります。 (ナビゲーション引き出して、メニュー付き)

  1. ツールバー
  2. GAP:ディスプレイには、以下のようなものです! < ---私はここにギャップがあることを望んでいない!
  3. ListView1の
  4. ハトムギ

これは表示を望みません。

理想的には、私は次のことをしたい:

  1. (ナビゲーション引き出して、メニュー付き)ツールバー
  2. ListView1の
  3. GAPはここ
  4. ハトムギ

すべてのヘルプははるかにあるべきです感謝。ありがとう。

+0

問題のスクリーンショットを追加できますか? – motis10

+0

お返事ありがとうございます。しかし、私は上記のように私のレイアウトのすべてを保持する問題を修正しましたが、match_parentへのlistView1のlayout_heightのみを変更しました。 – Dopinder

答えて

0

あなたの要件に合わせて1つのレイアウトファイルを書きます。私はそれが役に立ちそうです

<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

お返事ありがとうございます。しかし私は自分のレイアウトを保持しながら問題を修正しましたが、listView1のlayout_heightをmatch_parentに変更しました。 – Dopinder

関連する問題