大佬教程收集整理的这篇文章主要介绍了android – 具有不同列大小的GridView,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
foo 1000 bar 876 foobar 500 foobarfoo 1
我目前正在使用GridView.我想将名称列宽设置为屏幕的60%,将得分列宽度设置为40%.可能吗?
目前我正在通过costuR_913_11845@适配器尝试.这是getview功能:
public View getView(int position,View convertView,ViewGroup parent) { TextView tv; if (convertView == null) { tv = new TextView(context); tv.setTextSize(25); tv.setTextColor(Color.WHITE); if (position % 2 == 0) { tv.setLayoutParams(new GridView.LayoutParams((width/10)*6,50)); } else { tv.setLayoutParams(new GridView.LayoutParams((width/10)*4,50)); } } else { tv = (TextView) convertView; } tv.setText(texts[position]); return tv; }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://scheR_913_11845@as.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/top"> <GridView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="2" android:id="@+id/grid" android:numcolumns="2" android:columnWidth="0dp" > </GridView> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/BACkbutton" android:text="@String/BACkstr"></Button> </LinearLayout>
所以问题再次出现:是否可以设置GridView以添加不同大小的列?如果是,那我的方法是好的? (可能不是,因为它不起作用:))我只是错过了什么?
先感谢您!
我们的实现检查特殊视图以及是否已实现新布局:
@Override protected void layoutChildren(){ super.layoutChildren(); if(!isSpecial || layoutAlreadySet) return; layoutAlreadySet = true; //Implement special layout.... }
以上是大佬教程为你收集整理的android – 具有不同列大小的GridView全部内容,希望文章能够帮你解决android – 具有不同列大小的GridView所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。