我有一个简单的 ListView 显示一些内容。有真实的内容视图@+id/conetnt
和一个视图@+id/service_disabled
只是为了显示一些花哨的背景,以防项目被禁用。禁用视图的背景应绘制在内容之上。这就是不为内容视图使用背景状态选择器的原因。
内容视图的高度因项目而异。我基本上希望禁用的视图高度与内容视图的高度相同。
但无论我尝试什么,在 API<11 上,禁用的视图高度match_parent
都会被忽略。禁用的视图只有很小的高度。在 API>=11 上一切都很好。
我的列表项布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/service_item_padding">
<!-- views... -->
</LinearLayout>
<View android:id="@+id/service_disabled"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_disabled_service_repeat"/>
</FrameLayout>
任何想法如何在 API<11 上解决这个问题?
顺便说一句:minSdk=8,targetSdk=18
它在运行 android-17 的 N4 和 tf101 上运行良好。它在我运行 android-10 的 HTC G2 上坏了。