Android自定义GridView显示一行,并且可以左右滑动
2013-03-21 16:15
771 查看
最近做一个类似滑动菜单栏的title,绑定数据源用的是GrildView,想要实现横着滑动并且GrildView只显示一行。最终采用代码形式在Activity中动态的添加布局实现。
布局文件采用了HorizontalScrollView 这个控件来控制左右滑动。
ViewGroup.LayoutParams params = dishtype.getLayoutParams(); // dishtype,welist为ArrayList int dishtypes = welist.size(); params.width = 115 * dishtypes; Log.d("看看这个宽度", params.width+""+welist.size()); dishtype.setLayoutParams(params); //设置列数为得到的list长度 dishtype.setNumColumns(welist.size());
布局文件采用了HorizontalScrollView 这个控件来控制左右滑动。
<HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none" > <FrameLayout android:layout_width="match_parent" android:layout_height="80dp" > <LinearLayout android:id="@+id/liear" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <GridView android:id="@+id/dishtype" android:layout_width="match_parent" android:layout_height="80dip" android:cacheColorHint="#00000000" android:columnWidth="108dip" android:gravity="center" android:horizontalSpacing="1.0dip" android:listSelector="#00000000" android:numColumns="auto_fit" android:stretchMode="spacingWidthUniform" android:verticalSpacing="1.0dip" > </GridView> </LinearLayout> </FrameLayout> </HorizontalScrollView>
相关文章推荐
- Android自定义GridView显示一行,并且可以左右滑动
- Android GridView显示一行,左右滑动
- Android GridView显示一行,左右滑动
- Android GridView显示一行,左右滑动
- android实现界面左右滑动(GridView动态设置item,支持每个item按某个属性排序来显示在不同的界面)
- GridView只显示一行,可以横着滑动
- Android自定义ListView和GridView解决滑动冲突和显示不全
- android实现界面左右滑动(GridView动态设置item,支持每个item按某个属性排序来显示在不同的界面)
- Android TableFixHeaders 最后添加一行计算总和,上下不能滑动,左右可以滑动
- android实现界面左右滑动(GridView动态设置item,支持每个item按某个属性排序来显示在不同的界面)
- android实现界面左右滑动(GridView动态设置item,支持每个item按某个属性排序来显示在不同的界面)
- Android GridView横向滑动 ,并且可限制Gridview显示行数!
- 禁止了gridview的滑动,并且解决了当一个滑动控件包裹这个gridview时,gridview只显示一行的问题
- Android实现了复杂表格,表格内容区域可以与上下滑动、左右滚动,并且标题会跟着滚动
- 自定义窗口大小并且让定义在自定义窗口的什么位置显示,窗口可以拖动。
- Android 自定义GridView,解决嵌套Grideview的显示不完全的问题
- Android菜鸟练习第二十四课 Android ScrollView嵌套GridView导致GridView只显示一行item
- Android在ListView中嵌套一个GridView时只显示一行的原因及解决方法
- android gridview左右滑动 并能定位
- Android自定义预定日历,并且显示阴历