2011.09.14——— android listview的横向滚动

本文介绍了一种实现 Android ListView 横向滚动的方法,通过在外层使用 HorizontalScrollView 和 LinearLayout 容器来达到 item 过长时可以横向滚动的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2011.09.14——— android listview的横向滚动

参考:[url]http://topic.youkuaiyun.com/u/20100817/22/0337960e-fe08-4aff-8d48-2aeb3c9cc3f7.html[/url]
[url]http://www.eoeandroid.com/thread-75501-1-1.html[/url]


问题:item过长 需要listview横向滚动显示
解决:listView外层加一个线性容器 然后在线性容器外边加一个HorizontalScrollview 即可

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

<HorizontalScrollView

android:id="@+id/horizontalScrollView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

<LinearLayout

android:layout_width="fill_parent"

android:id="@+id/linearLayout1"

android:layout_height="fill_parent"
android:layout_width="wrap_content"

android:orientation="horizontal">

<ListView

android:id="@+id/list1"

android:layout_height="wrap_content"

android:layout_width="fill_parent"></ListView>

</LinearLayout>

</HorizontalScrollView>
</LinearLayout>


效果如下图:

[img]http://dl.iteye.com/upload/attachment/553728/81d2989b-b6d5-3bb6-916c-850575fe08fe.jpg[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值