我按照这个教程来创建一个 的GridView
I follow this tutorial to create a GridView:
这行:
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
尺寸85x85是伟大的,我的野火,但在HTC Desire的它看起来非常小。 根据屏幕我怎样才能改变图像大小?
Size 85x85 is great for my Wildfire, but on HTC Desire it looks very small. How can I change the image size according to the screen?
我有2个不同的布局,但的GridView
还没有在XML文件中的任何属性来改变图片大小。
I have 2 different layouts, but Gridview
hasn't any attribute in the XML files to change the image size.
您可以尝试进行调整基于关闭当前设备,你是对的像素密度。
You could try to make an adjustment based off the pixel density of the current device you are on.
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
switch(metrics.densityDpi){
case DisplayMetrics.DENSITY_LOW:
imageView.setLayoutParams(new GridView.LayoutParams(lowVal, lowVal));
break;
case DisplayMetrics.DENSITY_MEDIUM:
imageView.setLayoutParams(new GridView.LayoutParams(medVal, medVal));
break;
case DisplayMetrics.DENSITY_HIGH:
imageView.setLayoutParams(new GridView.LayoutParams(highVal, highVal));
break;
}
上一篇:你怎么能强制WCF使用的xs:XS,而不是所有的:序列使SOAP元素顺序是无关紧要的?有的、你怎么、无关紧要、序列
下一篇:为什么运行时显示的一般类型为" GenericType`n"?类型、QUOT、GenericType