ListView不滚动。只是列表视图
我已经尝试了很多东西,但仍然不滚动我添加滚动条,即使它不相关。我试图改变焦点,但仍然没有滚动。 这里是fragment_contacts.xml我的Contacts_list.xmlListView不滚动。只是列表视图
<?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"
/>
代码和代码被包括在上面的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>
这是我的完满成功代码
试试这个XML为列表视图
<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>
删除此行并使用make custome行并使用baseadapter工具使用:listitem =“@ layout/fragment_contacts” –
使用布局象下面这样Contacts_list.xml XML,也不需要包括滚动条。
<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>
layout_height wrap_content ???你有没有试过这个。它看起来不正确。 –
我只是给了一个想法,而不是在ListView中添加所有内容(如边距等),使用LinearLayout并在其中包含listview。 – theremin
你是否足够填充listview滚动? –
是的,我有近15个联系人。添加了我自己。 –
在列表视图中尝试android:layout_height =“wrap_content” –