2017-01-12 3 views
0

Я разрабатываю приложение для Android. В моем основном действии есть несколько ящиков для навигации. Они определяются следующим образом:Android ListView обертывает внутри родителя, пока он не должен

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

<LinearLayout 
    android:id="@+id/drawer_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"/> 
<ListView android:id="@+id/left_drawer" 
    android:layout_width="240dp" 
    android:layout_height="fill_parent" 
    android:layout_gravity="left" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/black" 
    android:dividerHeight="5dp" 
    android:background="#e1fcff" 
    /> 
<ListView android:id="@+id/right_drawer" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="end" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/black" 
    android:dividerHeight="5dp" 
    android:background="#e1fcff" 
    android:layout_marginLeft="-64dp" 
    /> 

<ListView android:id="@+id/contacts_drawer_right" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="end" 
    android:choiceMode="singleChoice" 
    android:divider="#ffff2a00" 
    android:dividerHeight="5dp" 
    android:background="#e1fcff" 
    android:layout_marginLeft="-64dp" 
    /> 

Я заполнить "contacts_drawer_right ListView" с RelativeLayout, который имеет ListView (с идентификатором = contactsListView) в его внутри тоже.

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:orientation="vertical"><ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <ListView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:id="@+id/contactsListView" 
      /> 
    </ScrollView> 
    </RelativeLayout> 

Моей проблема заключается в том, что, то contactsListView не заполняет его родители высоты, хотя я использовал android:layout_height="fill_parent" в этом файле макета определения. Мое ожидание похоже на следующее: enter image description here Но то, что происходит на самом деле, выглядит следующим образом: enter image description here Кроме того, я не могу прокрутить список.

, пожалуйста, дайте мне идеи и покажите мне, как я могу показать все содержимое своего списка (с заполненным родителем).

ответ

0

Попробуйте сделать это, сделать Scrollview родитель:

<?xml version="1.0" encoding="utf-8"?> 

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
     <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 
       <ListView 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@+id/contactsListView" 
       /> 
     </RelativeLayout> 
</ScrollView> 
+0

снова не работает :( – ai68

+0

вы можете удалить Scrollview, если вы просто хотите ListView .... ListView уже прокручивать почему вы хотите добавить scrollView ?? – MezzyDroid

Смежные вопросы