我试着去得到一个GridView显示的图像,并获得自动设置列,到目前为止,我不得不手动设置列的数量,这是不是我想要做的,因为这会影响到图像有多大的不同大小的屏幕。我ahve试图把它置auto_fit但它只是在屏幕中间显示2列。这是我尝试实现:(每红场再presents图像)
im trying to get images displayed in a GridView and get the columns automatically set, so far I've had to manually set the number of columns which is not what i want to do as this will affect how big the images are on different sized screens. I ahve tried setting it to auto_fit but it only displays 2 columns in the middle of the screen. This is what im trying to achieve: (Each red square represents an image)
那么当转向横向模式我想列自动调整,使所有的偶数。 任何帮助将是非常美联社preciated,谢谢:)
then when turned to landscape mode i want the columns to auto fit so that its all even. Any help would be much appreciated, thank you :)
实验与GridView控件的属性,特别是机器人:为numColumns =auto_fit
和 Android的:stretchMode
。对我来说,以下工作:
Experiment with the GridView attributes, specifically android:numColumns="auto_fit"
and android:stretchMode
. The following works for me:
<GridView
android:id="@+id/myGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
上一篇:使用裁剪意图获取java.lang.SecurityException异常:无法找到应用程序的调用者android.app.ApplicationThreadProxy@4266ae80意图、应用程序