grIDvIEw布局
<?xml version="1.0" enCoding="utf-8"?><GrIDVIEw xmlns:androID="http://schemas.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://schemas.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://schemas.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
@OverrIDepublic 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使项目适合每个屏幕尺寸所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)