首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ListView不是scrolling.Just列表视图

ListView不是scrolling.Just列表视图
EN

Stack Overflow用户
提问于 2016-01-06 21:48:55
回答 2查看 87关注 0票数 0

我尝试了很多东西,但仍然没有滚动,我添加了滚动条,尽管它是无关的。我试着改变焦点,但仍然没有滚动。下面是我的Contacts_list.xml代码

代码语言:javascript
复制
<?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的代码。

代码语言:javascript
复制
<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>

这是我的完整代码

EN

回答 2

Stack Overflow用户

发布于 2016-01-06 21:53:42

尝试将此xml用于listview

代码语言:javascript
复制
<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>
票数 0
EN

Stack Overflow用户

发布于 2016-01-06 22:01:53

在Contacts_list.xml中使用像下面这样的布局,并且不需要包含滚动条。

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34634729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档