Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ListView不会滚动。什么都试过了_Android_Xml_Listview_Android Listview - Fatal编程技术网

Android ListView不会滚动。什么都试过了

Android 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.

好的,我有一个不滚动的列表视图。我试了所有被要求的东西

1-列表中有足够的项目使其可滚动

2-它不在滚动视图中

3-我尝试过改变它的高度以包装内容并匹配父对象

4-我在listview中有一个图像,我已将可聚焦设置为false。 什么都试过了。我想放弃。这是我的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" />

这是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">