电网对不同设备的数量电网、数量、不同、设备

2023-09-06 14:05:00 作者:沵湜莪嘸琺企及的光

我有一个问题,我应该知道每一行中的GridView 这被显示为不同的设备的数量。如的GridView 每行的片数,WVGA手机..since其屏幕宽度不同..是有一个code检查这个?

I have a problem where i should know the number of gridviewin each row which gets displayed for different devices. like number of gridview per row for tablets, WVGA phones ..since their screen widths are different ..is there a code to check this?

推荐答案

OKK​​您可以用编程方式设置的列数

Okk you can set number of columns programatically using

float scalefactor = getResources().getDisplayMetrics().density * 100;
int number = getWindowManager().getDefaultDisplay().getWidth();
int columns = (int) ((float) number / (float) scalefactor);
gridView.setNumColumns(columns);

其中100是每个列对M取所有设备的固定宽度......我得到的平板电脑,3 8列三星三星笔记2.2设备和4

where 100 is the fixed width of each column for all devices m taking...i get 8 columns in tablet,3 in samsung 2.2 devices and 4 in samsung note

 
精彩推荐
图片推荐