android 单行gridview横向滑动的实现
来源:互联网 发布:郑州淘宝诈骗案最新 编辑:程序博客网 时间:2024/05/18 00:28
android 单行gridview横向滑动的实现
首先重写下GridView
HorizontalGridView.java
public class HorizontalGridView extends GridView { public HorizontalGridView(Context context, AttributeSet attrs) { super(context, attrs); } public HorizontalGridView(Context context) { super(context); } public HorizontalGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int childCount = getChildCount(); int childWidth = CommonUtil.dip2px(88); int childHeight = CommonUtil.dip2px(120); int lastPadding = CommonUtil.dip2px(10); int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(expandSpec , heightMeasureSpec); //设置GridView的宽度 setMeasuredDimension(childCount * childWidth + lastPadding, childHeight); }}
然后是GridView的布局文件的
<HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <你项目的包名.HorizontalGridView android:id="@+id/gv_my_game" android:layout_width="wrap_content" android:layout_height="wrap_content" android:columnWidth="88dp" android:divider="@null" android:horizontalSpacing="0dp" android:listSelector="@drawable/item_bg" android:numColumns="auto_fit" android:scrollbars="none" /> </HorizontalScrollView>
然后 就可以 使用 单行横向滑动的GridView了
1 3
- android 单行gridview横向滑动的实现
- Android多行gridview横向滑动的实现
- Android实现横向滑动的GridView
- Android中单行横向滑动的日历
- Android横向滑动的GridView
- 横向滑动的GridView
- andorid gridview 单行横向显示 横向滚动实现
- andorid gridview 单行横向显示 横向滚动实现
- 单行横向滑动的日历calendar控件
- 另一种可左右滑动的横向GridView的实现
- 使用ViewPager+GridView实现横向滑动的效果(一)
- 使用ViewPager+GridView实现横向滑动的效果(二)
- 使用ViewPager+GridView实现横向滑动的效果(一)
- 使用ViewPager+GridView实现横向滑动的效果(二)
- Android 自定义横向滑动菜单的实现
- HorizontalScrollView嵌套GridView实现横向滑动
- ViewPager+GridView实现横向滑动 仿美团
- HorizontalScrollView 和GridView 实现横向滑动
- Integer 和 int 判断相等
- HTTPS访问中证书的处理
- html5 文件上传预览
- OpenCV鼠标修改图片透明度
- PHP5 扩展SOAP 调用 webservice
- android 单行gridview横向滑动的实现
- apapche在windows2008服务器运行一段时间后服务关闭
- 数字证书原理(转载)
- Android之使用PackageManager取得程序的包名、图标等
- 149.Max Points on a Line
- mysql sql语句总结
- HKLM\SOFTWARE\Microsoft\WindowsCurrentVersion\Run里面的启动项不启动了
- 不可编写返回可变引用对象的访问器方法
- codeforces #311 C 557C. Arthur and Table(枚举+贪心)