为什么我的列表视图不滚动? [英] Why is my listview not scrolling?

查看:92
本文介绍了为什么我的列表视图不滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < RelativeLayout的
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:后台=#dad4c8
    机器人:重力=center_horizo​​ntal>
    <包括
        机器人:ID =@ + ID / title_bar
        布局=@布局/ title_bar/>
    <的EditText
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / title_bar
        机器人:ID =@ + ID / TXT
        机器人:提示=歌名/>

    <的ListView
        机器人:cacheColorHint =#00000000
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / TXT
        机器人:ID =@ + ID /列表/>

< / RelativeLayout的>
 

解决方案

使用的LinearLayout,并设置ListView的高度,以0dip,并给它 layout_weight =1

这将使它自动填充任何剩余的空间,从而引起列表视图中滚动的内部物品。目前,该列表视图是非常高的,并且被裁剪的屏幕范围。

修改

事情是这样的:

 <的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:后台=#dad4c8
    机器人:方向=垂直
    机器人:重力=center_horizo​​ntal>
    <包括
        机器人:ID =@ + ID / title_bar
        布局=@布局/ title_bar/>
    <的EditText
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:ID =@ + ID / TXT
        机器人:提示=歌名/>

    <的ListView
        机器人:cacheColorHint =#00000000
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =0dip
        机器人:layout_weight =1
        机器人:ID =@ + ID /列表/>

< / LinearLayout中>
 

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#dad4c8"
    android:gravity="center_horizontal">
    <include
        android:id="@+id/title_bar"
        layout="@layout/title_bar" />
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/title_bar"
        android:id="@+id/txt"
        android:hint="Song title" />

    <ListView
        android:cacheColorHint="#00000000"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/txt"
        android:id="@+id/list" />

</RelativeLayout>

解决方案

Use a LinearLayout and set the ListView's Height to 0dip and give it layout_weight="1"

This will make it autofill any remaining space, causing the internal items of the list view to scroll. Currently the listview is very tall and is being clipped by the bounds of the screen.

Edit

Something like this:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#dad4c8"
    android:orientation="vertical"
    android:gravity="center_horizontal">
    <include
        android:id="@+id/title_bar"
        layout="@layout/title_bar" />
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txt"
        android:hint="Song title" />

    <ListView
        android:cacheColorHint="#00000000"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:id="@+id/list" />

</LinearLayout>

这篇关于为什么我的列表视图不滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆