在Kitkat上工作正常,但在API 8(真实设备)和模拟器中存在问题。
图像:
http://i.stack.imgur.com/wY33Y.png
代码:
- 主要布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:background="@drawable/inner_background"
android:layout_height="wrap_content" >
<GridView
android:id="@+id/busListGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="0px"
android:background="#00000000"
android:listSelector="@drawable/bus_grid_selector"
android:numColumns="3"
android:scrollbarSize="3dp"
android:scrollbarStyle="insideInset"
android:scrollbarThumbVertical="@drawable/custom_scroll_style_busgrid" >
</GridView>
</RelativeLayout>
- 自定义适配器的单项xml:
<?xml version="1.0" encoding="utf-8"?>
<lv.sezy.satiksme.rezekne.layouts.SquareView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bus_grid_selector" >
<LinearLayout
android:id="@+id/busGridSingleHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@drawable/empty"
android:orientation="horizontal" >
<TextView
android:id="@+id/bus_number"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center_vertical|center"
android:text="@string/tester"
android:textColor="@color/busGridTextColor"
android:textSize="60sp"
android:textStyle="bold" />
</LinearLayout>
</lv.sezy.satiksme.rezekne.layouts.SquareView>
- bus_grid_selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bus_grid_regular" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/bus_grid_focus" android:state_pressed="true" android:state_selected="true"/>
<item android:drawable="@drawable/bus_grid_focus" android:state_pressed="true"/>
</selector>
- bus_grid_regular:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="0dp"
android:left="-2dp"
android:right="0dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="1dp"
android:color="#90FFFFFF" />
<solid android:color="#00FFFFFF" />
</shape>
</item>
</layer-list>
我能够通过添加
来解决与ListView类似的问题android:cacheColorHint =“#00000000”
总线它对GridView没有帮助。
答案 0 :(得分:0)
问题在于LinearLayout背景@ drawable / empty,这只是空的形状。 看来API8将空形状解释为黑色形状。