Android使用GridView内容填充满不出现滚动的设计
2016-07-08 18:46
405 查看
GridView显示不完成的原因是因为,他的外层也套用了一个滑动的控件,解决的方法就是重写GridView,使控制GridView不能滚动,就是写一个类继承GridView。代码如下:
public class TagsGridView extends GridView
{
public TagsGridView(Context context) {
super(context);
}
//该方法起了重要作用
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec=MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
public class TagsGridView extends GridView
{
public TagsGridView(Context context) {
super(context);
}
//该方法起了重要作用
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec=MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
相关文章推荐
- Android 状态栏、titlebar的高度计算
- Android在Fragment中嵌套(添加)Fragment
- android常见笔试题
- android打包
- android打包
- Android中杀进程的几种方法 (1) - killBackgroundProcesses
- imx6 android开机启动守护进程
- Android四大基本组件介绍与生命周期
- Android wait notify sleep 与死锁问题举例
- Android中RecyclerView嵌套RecyclerView或嵌套ListView
- android studio 搭建opencv环境 (接上一篇文章)
- 第一行代码-Android 学习笔记(一)
- android 界面布局
- android中的Activity
- 无限滚动的轮播图
- Android ActionBar完全解析,使用官方推荐的最佳导航栏(上)
- Android 程序流量监控
- 【Android】ListView修改item布局与内部数据
- android 方向传感器Sensor或指南针罗盘研究
- Android Studio下的.gitignore