Android ListView不会滚动。什么都试过了
好的,我有一个不滚动的列表视图。我试了所有被要求的东西 1-列表中有足够的项目使其可滚动 2-它不在滚动视图中 3-我尝试过改变它的高度以包装内容并匹配父对象 4-我在listview中有一个图像,我已将可聚焦设置为false。 什么都试过了。我想放弃。这是我的fragment_list.xmlAndroid ListView不会滚动。什么都试过了,android,xml,listview,android-listview,Android,Xml,Listview,Android Listview,好的,我有一个不滚动的列表视图。我试了所有被要求的东西 1-列表中有足够的项目使其可滚动 2-它不在滚动视图中 3-我尝试过改变它的高度以包装内容并匹配父对象 4-我在listview中有一个图像,我已将可聚焦设置为false。 什么都试过了。我想放弃。这是我的fragment_list.xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.
<?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" />
这是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>
如果有问题,我会提供额外的信息。
我有main.xml,里面有一个寻呼机
<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">
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
在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">
使用CoordinatorLayout时使用recycleview而不是listview我想这是我的最后一个选项???您是否在ScrollView中使用listview?listview是否在简单的LinearLayout包装中滚动这是一个简单的示例?@UmerAsif,我想说的是,只需单独测试xml文件,以检查哪个块会给您这个意外的结果。远程查找此错误并不困难。
<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">