2016-11-02 5 views
0

다음 레이아웃을 사용하고 있습니다. 기본적으로 사용자 정의 도구 모음, 탐색 창, 메뉴, ListView (listView1) 및 채우기가 있습니다.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> 

레이아웃 종류의 다음과 같은 순서처럼되어

  1. 도구 모음
  2. listView1
  3. 율무

listView1 (탐색 창 및 메뉴) 목록으로 구성 외부 XML 파일에서로드 된 항목 수

문제가 있습니다. listView1의 항목이 그리 많지 않은 경우, 아래쪽으로 내려가 adlay 위에 위치하며 도구 모음과 listView1 사이에 listView1 위에 간격이 있습니다. 디스플레이는 다음과 같다 :

  • GAP (탐색 창 및 메뉴)

    1. 도구 모음! < --- 나는 그 격차가 여기 있기를 원하지 않는다!
    2. listView1
    3. 율무이 표시를 원하지 않는

    .

  • 율무
  • 어떤 도움이 많이

  • GAP 여기에 있어야한다
  • listView1 (탐색 창 및 메뉴)

    1. 도구 모음 :

      이상적으로, 나는 다음 원하는 고맙습니다. 감사.

  • +0

    문제의 스크린 샷을 추가 할 수 있습니까? – motis10

    +0

    답변 해 주셔서 감사합니다. 하지만 위와 같이 레이아웃에서 모든 것을 유지하면서 문제를 해결했지만 listView1의 layout_height 만 match_parent로 변경했습니다. – Dopinder

    답변

    0

    귀하의 요구 사항에 맞는 하나의 레이아웃 파일을 작성합니다. 유용 할 것입니다.

    <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

    관련 문제