1

私はこれらの 2 つの 9 パッチを持っています:

ここに画像の説明を入力

ここに画像の説明を入力

ここに私のXMLがあります:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/switch_bg"
    android:layout_width="45dp"
    android:layout_height="32dp"
    android:background="@drawable/switch_bg_off"
    android:padding="0dp" >

    <ImageView
        android:id="@+id/switch_bg2"
        android:layout_width="45dp"
        android:layout_height="32dp"
        android:layout_centerInParent="true"
        android:src="@drawable/switch_bg_off" />

<RelativeLayout
    android:id="@+id/switch_handle"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:background="@drawable/switch_handle"
    android:padding="0dp" >

    <ImageView
        android:id="@+id/switch_v"
        android:layout_width="15dp"
        android:layout_height="15dp"
        android:layout_centerInParent="true"
        android:src="@drawable/switch_v" />

</RelativeLayout>

</RelativeLayout>

しかし、グラフィックエディタと私のアプリ自体で

白いボックスは半分にカットされ、不適切に表示されます:

ここに画像の説明を入力

どうすればこれを修正できますか?

4

1 に答える 1

0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/switch_bg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/switch_bg_off"
    android:padding="0dp" >

    <ImageView
        android:id="@+id/switch_bg2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/switch_bg_off" />

<RelativeLayout
    android:id="@+id/switch_handle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:background="@drawable/switch_handle"
    android:padding="0dp" >

    <ImageView
        android:id="@+id/switch_v"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/switch_v" />

</RelativeLayout>

</RelativeLayout>
于 2013-10-31T10:48:09.877 に答える