简体   繁体   中英

ListView not scrolling.Just Listview

I have tried a lot of things but still not scrolling i added scrollbars even though it was not related. i tried to change focus but still no scrolling. Here is my code for Contacts_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/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    tools:context="Contacts_fragment"
    tools:listitem="@layout/fragment_contacts"
    android:scrollbars="vertical"
       />

and code for fragment_contacts.xml which is included in above xml.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="1"
android:gravity="bottom">

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

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/phone"
    android:textSize="14sp"
    android:gravity="bottom"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@+id/image"
    android:layout_toEndOf="@+id/image" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:id="@+id/name"
    android:textSize="16sp"
    android:textStyle="bold"
    android:gravity="top"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/image"
    android:layout_toEndOf="@+id/image" />
     </RelativeLayout>

This is my complet Code

Try this xml for listview

<ListView
        android:id="@+id/sampleListView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        tools:listitem="@layout/fragment_contacts"
        >
</ListView>

Use Layout like below xml in Contacts_list.xml and no need to include scroll bar.

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

     <ListView
          android:id="@+id/list"
          android:layout_height="wrap_content"
          android:layout_width="match_parent">
      </ListView>


 <LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM