我尝试了很多东西,但仍然没有滚动,我添加了滚动条,尽管它是无关的。我试着改变焦点,但仍然没有滚动。下面是我的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"
/>以及包含在上述xml中的fragment_contacts.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>这是我的完整代码
发布于 2016-01-06 21:53:42
尝试将此xml用于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>发布于 2016-01-06 22:01:53
在Contacts_list.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>https://stackoverflow.com/questions/34634729
复制相似问题