我有两个九个补丁:
这是我的 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>
但是在图形编辑器和我的应用程序本身
白盒被切成两半,看得不正确
我该如何解决这个问题?
答案 0 :(得分: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>