2016-01-09 1 views
0

Ok, j'ai un listView qui ne défile pas. J'ai essayé tout ce qui a été demandé sur SO.Android ListView ne défile pas. J'ai tout essayé

1- J'ai suffisamment d'éléments dans la liste pour le faire défiler.

2- Il n'est pas dans un ScrollView.

3- J'ai essayé de changer sa hauteur à wrap_content et match_parent

4- J'ai une image dans listview J'ai mis focusable faux. Tout essayé. J'ai envie d'abandonner. Ceci est mon fragment_list.xml

<?xml version="1.0" encoding="utf-8"?> 
<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/contacts" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_marginLeft="16dp" 
android:layout_marginRight="16dp" 
android:scrollbars="vertical" 
android:focusable="true" 
tools:listitem="@layout/fragment_contacts" /> 

et c'est fragment_contacts.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" 
> 

<ImageView 
    android:id="@+id/image" 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:contentDescription="@string/Description" 
    android:focusable="false"/> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="60dp" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textSize="16sp" 
     android:textStyle="bold" 
     android:layout_marginLeft="14dp"/> 

    <TextView 
     android:id="@+id/phone" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="top" 
     android:textSize="14sp" 
     android:layout_marginTop="15dp" 
     android:layout_marginLeft="14dp" /> 
</LinearLayout> 

Maintenant, je suis donner des informations supplémentaires va s'il y a le problème. J'ai le fichier main.xml qui contient un pager.

<android.support.design.widget.CoordinatorLayout   xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="context"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     /> 


    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabMode="fixed" 
     app:tabGravity="fill" 

     /> 
    <android.support.v4.view.ViewPager 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/backscreen3" 
     /> 


</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_main" /> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="context" 
tools:showIn="@layout/activity_main" 
> 

S'il vous plaît me aider à résoudre ce problème.

+1

utilisation recycleview insted de listview lors de l'utilisation CoordinatorLayout –

+0

je suppose que cela est le dernier option que j'ai ??? –

+0

Avez-vous utilisé listview dans ScrollView? – sasikumar

Répondre

0

Mettre le ListView dans un RelativeLayout comme celui-ci

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ListView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

0

Définissez cette propriété dans votre ListView

<ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:dividerHeight="0dp" 
     android:listSelector="@android:color/transparent">