这是我的简单背景选择器:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/filters_group_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/filters_group_pressed" android:state_selected="true"/>
<item android:drawable="@drawable/filters_group"/>
</selector>
在布局编辑器布局中,看起来像:
在nexus 7(第一代)上发布之后,它看起来像:
如果我设置为背景我的9patch图形(哪个选择器包含)而不是选择器,它看起来很好。它对我来说看起来像是一个安卓漏洞......
白色条应以整个宽度拉伸,图标应居中。这是布局:
<org.mycustomview.MyCustomLinearLayout
android:id="@+id/group_button"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/filter_group_button_selector"
android:gravity="center"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="@+id/icon_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_table" />
<TextView
android:id="@+id/title_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sala 1"
android:lines="1"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:background="@color/white"
android:gravity="center"
android:textColor="@color/white" />
</org.mycustomview.MyCustomLinearLayout>
答案 0 :(得分:0)
一定是个bug。它添加了右边填充本身。我将android:paddingRight="0dp"
添加到我的MyCustomLinearLayout
,它的工作方式与预期相符。