Android自定义GridView显示一行,并且可以左右滑动
来源:互联网 发布:三年饥荒 知乎 编辑:程序博客网 时间:2024/05/09 11:11
最近做一个类似滑动菜单栏的title,绑定数据源用的是GrildView,想要实现横着滑动并且GrildView只显示一行。最终采用代码形式在Activity中动态的添加布局实现。
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>
0 0
- Android自定义GridView显示一行,并且可以左右滑动
- Android GridView显示一行,左右滑动
- Android GridView显示一行,左右滑动
- Android GridView显示一行,左右滑动
- GridView只显示一行,可以横着滑动
- Android GridView横向滑动 ,并且可限制Gridview显示行数!
- 缩略图预览大图并且可以左右滑动
- android gridview左右滑动(二)
- Android TableFixHeaders 最后添加一行计算总和,上下不能滑动,左右可以滑动
- android自定义控件--条目可以左右滑动的listview
- GridView实现一行显示并左右滚动
- GridView实现一行显示并左右滚动
- 自定义两行可左右滑动的GridView
- 禁止了gridview的滑动,并且解决了当一个滑动控件包裹这个gridview时,gridview只显示一行的问题
- android gridview左右滑动 并能定位
- overflow 显示一行可以滑动,不显示滑动滚动条
- Android实现了复杂表格,表格内容区域可以与上下滑动、左右滚动,并且标题会跟着滚动
- android自定义布局-ScrollLayout 实现左右滑动
- ci使用随记 1
- java 面向对象基础 实例方法与类方法 this 包 访问权限 私有 共有 友好 保护
- iOS生成静态库方法-iOS集成静态库-iOS合并静态库
- Java Map练习与实际应用
- jdk1.4 使用RSA加解密
- Android自定义GridView显示一行,并且可以左右滑动
- Leetcode 7. Reverse Integer
- cocoPods #import 不提示第三方库
- HDU 4160Dolls (二分图)
- 【c++】深度探索虚继承内存布局
- OF+SHADER的第一个程序
- leetcode 6. ZigZag Conversion
- C# FluentNHibernate 连接mysql数据库
- heartbeat个人学习整理