当前位置:操作系统 > 安卓/Android >>

android listview的横向滚动

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

Java代码 
<?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> 


效果如下图:

作者“TryLoveCatch”
 

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,