设置不要在控间中滑动:

public class DeliverGridView  extends GridView {
public DeliverGridView(Context context, AttributeSet attrs) {
super(context, attrs);
} public DeliverGridView(Context context) {
super(context);
} public DeliverGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
} @Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec);
} }

布局文件:

    <com.andruby.cigarette.views.DeliverGridView
android:id="@+id/cighome_gridview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@color/grey"
android:cacheColorHint="#00000000"
android:horizontalSpacing="1.0dip"
android:listSelector="@null"
android:numColumns="3" android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="1.0dip" android:layout_weight="2"/>

设置gv占整个界面的权重:(一个5一个2总7)

    DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
// 屏幕宽度(像素)
int win_height = metric.heightPixels;
int height = win_height*2/7;

在adapter的getView()中:

if (convertView == null) {
convertView = LayoutInflater.from(ac).inflate(
R.layout.grid_item, null); AbsListView.LayoutParams param = new AbsListView.LayoutParams(
android.view.ViewGroup.LayoutParams.FILL_PARENT,
height /2); //height是传过来的 convertView.setLayoutParams(param);
holder = new ViewHolder(); convertView.setTag(holder); holder.tv_share_item_title = (TextView) convertView
.findViewById(R.id.tv_share_item_title);
holder.tv_share_item_set = (ImageView) convertView
.findViewById(R.id.tv_share_item_set);
holder.lin_share_item = (LinearLayout) convertView
.findViewById(R.id.lin_share_item); } else {
holder = (ViewHolder) convertView.getTag();
}

gridview填充剩下的空间的更多相关文章

  1. Qt QLabel 大小随内容自动变化 && 内容填充整个label空间

    图1:label的本身大小 图2:给label设置文字,不做任何别的设置 ui->label->setText(QObject::tr("current font is %1&q ...

  2. video视频内容填充整个播放空间方法

    关于video视频内容填充整个播放空间方法一般上传的视频都没法占满video,看起来很不美观,解决办法很简单video{ object-fit:fill;}

  3. VC中出现“烫”和“屯”的原因(栈区的每一个字节都被0xCC填充了,也就是int 3h的机器码,动态分配的堆,VC的Debug用0xCD填充堆的空间,就出现了“屯”)

    相信经常用VC的朋友对屏幕输出的一大堆“烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫”不会陌生,但是也许会很奇怪,为什么会出现“烫”字呢?莫非改程序导致系统运行缓慢,发热过高???非也!下面让我解释 ...

  4. CStatic中保持图形比例不变,尽量填充控件空间的代码

    CStatic中保持图形比例不变,尽量填充控件空间的代码 先获取控件的高.宽,然后获取图像的高.宽,测试需要调整高还是调整宽 void CImagePreviewStatic::DrawItem(LP ...

  5. [Winform] DataGridView 总结(FAQ)

    Q1.  如何使单元格不可编辑? A:设置 ReadOnly 属性,可以设置的对象包括 DataGridViewRow(行).DataGridViewColumn(列).DataGridViewCel ...

  6. 操作系统开发系列—1.HelloWorld ●

    org 07c00h ;伪指令,告诉编译器程序会被加载到7c00处 mov ax, cs mov ds, ax mov es, ax call DispStr ;调用显示字符串例程 jmp $ ;无限 ...

  7. WPF自学笔记

    WPF使用哪几种元素作为顶级元素: 1. Window元素 2. Page元素(与Window元素类似,用于可导航的应用程序) 3. Application元素(定义应用程序资源和启动设置) PS:在 ...

  8. 《Orange‘s》 Bochs环境配置

    安装配置bochs之前先写一个简单的引导扇区用来测试: org 07c00h mov ax,cs mov ds,ax mov es,ax call DispStr jmp $ DispStr: mov ...

  9. 多种方法实现左右固定,中间自适应的CSS布局

    布局是面试中常问的问题,尤其是这类的题目,怎么答才好呢? 大多数人的第一个方法是浮动,没错,浮动.第二个方法呢?你回答定位,没错.第三个方法呢?.... 第四个方法呢?第五个方法呢?.... 其实能想 ...

随机推荐

  1. windows下安装xgboost

    Note that as of the most recent release the Microsoft Visual Studio instructions no longer seem to a ...

  2. LeetCode 328. Odd Even Linked List

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  3. cocos2d-x3.2创建新项目失败的一种可能性(cygwin自带的python2.6被抢先执行)

    之前一直使用cocos2d-x2.2写游戏,写了几个游戏后,想尝试下3.x版本的新功能,就下载了cocos2d-x3.2版本. 参照官方文档的说法,cocos2d-x3.x版本需要python2.7环 ...

  4. Oracle的exp/imp详解

    原文地址:Oracle的exp/imp详解 作者:jxlazzw 备份概述 逻辑备份:备份可分为两类 ,物理备份和逻辑备份 物理备份:该方法实现数据库的完整恢复,但需要极大的外部存储设备,例如磁带库, ...

  5. ABP的第一个程序和遇到的一些问题

    ABP在这里就不多介绍了.在这篇文章中主要介绍使用模板生成的ABP项目使用遇到的一些问题. 1.首先在http://www.aspnetboilerplate.com/ 官方网站上创建一个模板项目, ...

  6. Hive修改表

    Alter Table 语句 它是在Hive中用来修改的表. 语法 声明接受任意属性,我们希望在一个表中修改以下语法. ALTER TABLE name RENAME TO new_name ALTE ...

  7. mysql 连接空闲超8小时自动断开连接问题(linux)

    在mysql配置文件里添加wait_timeout和interactive_timeout两个值 [mysqld] wait_timeout= interactive_timeout= 超时时间,10 ...

  8. 后台使用Spring MVC 4.15 版本 通过 ajaxFileUpload plugin插件上传文件相应时引起的一个小问题,Chrome、Firefox中出现SyntaxError:unexpected token <

    html: 使用ajaxFileUpload插件做文件上传时,后台返回json格式的数据,js代码如下: 接下来,把结果错误信息打印出来: 先在网上找了下解决办法方案,stackoverflow上有说 ...

  9. angularjs中文社区

    http://angularjs.cn/   中文社区 https://angular.cn/features.html  官方文档中文版

  10. Linux:cacti环境部署

    一.监控端安装1)基础软件:安装配置cacti前,需要安装:httpd.php.mysqld.php-mysql.net-snmp.rrdtool以上均可使用yum安装:yum install -y ...