문제

Here is my simple background selector:

<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>

In the layout editor layout look's like: enter image description here

After launching on nexus 7 (first generation) it look's like: enter image description here

It looks fine if I set as background my 9patch graphic (which selector contains) and not the selector. It looks like an android bug to me...

White bar should be stretched at whole width and the icon should be centered. Here is the layout:

<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>
도움이 되었습니까?

해결책

It must be a bug. It added right padding itself. I added android:paddingRight="0dp" to my MyCustomLinearLayout and it's work like expected.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top