大佬教程收集整理的这篇文章主要介绍了Android GridView使项目适合每个屏幕尺寸,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
gridview布局
<?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://scheR_273_11845@as.android.com/apk/res/android" android:id="@+id/gridView1" android:numcolumns="11" android:gravity="center" android:stretchMode="columnWidth" android:layout_width="fill_parent" android:layout_height="fill_parent" > </GridView>
item.xml
<?xml version="1.0" encoding="utf-8"?> <Button xmlns:android="http://scheR_273_11845@as.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="O" android:id="@+id/grid_item_label" android:layout_column="1" android:BACkground = "@drawable/roundedbutton"/>
roundedbutton.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://scheR_273_11845@as.android.com/apk/res/android" android:shape="oval"> <solid android:color="#9F2200"/> <stroke android:width="2sp" android:color="#fff" /> <size android:width="5dp" android:height="5dp"/> </shape>
activity_main.java
gridView = (GridView) findViewById(R.id.gridView1); customGridAdapter = new CustomGridViewAdapter(this,R.layout.button_item,gridArray); gridView.setAdapter(customGridAdapter);
adapter.java
@Override public View getView(final int position,View convertView,final ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemservice(Context.LAYOUT_INFLATER_serviCE);
int width = devicewidth/11 ; int height =deviceheight/11 ;
使用此参数,您必须传入GridView的适配器
android.widget.AbsListView.LayoutParams parms = new android.widget.AbsListView.LayoutParams(width,height);
调整其细胞大小.
以上是大佬教程为你收集整理的Android GridView使项目适合每个屏幕尺寸全部内容,希望文章能够帮你解决Android GridView使项目适合每个屏幕尺寸所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。