问题描述
||
我正在使用Gridview显示一些缩略图。我遇到的一个奇怪的问题是,如果清单中未指定android:minSdkVersion,则缩略图之间的间距应适当,但是如果我指定minSdkVersion(需要4个或更多),则缩略图将水平合并。
这个问题仅出现在我的测试电话T Mobile Pulse mini上,而在模拟器上却没有出现此类问题。
感谢对此提出的任何明智建议。
XML如下所示。
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
>
<!--thumbnails-->
<GridView
android:id=\"@+id/gridview\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:columnWidth=\"90dp\"
android:numColumns=\"auto_fit\"
android:verticalSpacing=\"10dp\"
android:horizontalSpacing=\"10dp\"
android:stretchMode=\"none\"
android:gravity=\"center\"
/>
</LinearLayout>
解决方法
API版本4之后提供属性“ auto_fit \”。
所以在行
android:numColumns=\"auto_fit\"
您将必须指定列数。
有关更多信息,请参阅
http://developer.android.com/reference/android/widget/GridView.html#AUTO_FIT