4

我需要 GridView 而不在 Android API 中填充小于 10。我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >

<GridView
    android:id="@+id/grid"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:alwaysDrawnWithCache="true"
    android:background="@color/gridview_background"
    android:clipChildren="true"
    android:horizontalSpacing="1dp"
    android:numColumns="6"
    android:verticalSpacing="1dp" />

结果:

在此处输入图像描述

红色箭头显示在填充上。它只在 Android < 3.0 我需要的结果

在此处输入图像描述

没有填充。

PS 在 android 3.0 上完全相同的代码没有填充。这是为什么?

4

2 回答 2

5

我几乎找不到答案=)。在 2.x Android 中,样式是您的 listSelector,而 4.x. 在 4.x 上他可能是空的,而 2.x 则比这还要多,并在吠叫上填写他需要放置的属性:

android: listSelector="@null"
于 2013-04-03T08:04:12.200 回答
0

我建议在 4.x SDK 下编译以获得您想要的行为,但包括您想要在 minSDK 中支持的设备。

建议使用 10 级/Android 3.0,因为 Honeycomb 只是 Android 的平板电脑化身。您可能希望以 API 级别 14 为目标,并且 minSDKVersion 为 8-10。

于 2013-02-07T04:07:50.197 回答