我正在使用
Android studio来编译项目. Project min SDK为14,目标为17.
我正在使用此代码.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <Switch android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Switch" android:id="@+id/switch" android:layout_alignBottom="@+id/button3" android:layout_toRightOf="@+id/button3" android:layout_marginLeft="44dp"/> </RelativeLayout>
解决方法
如果您将交换机的ID更改为“@ id / switch”以外的其他内容,则可以解决此错误.例如:
<Switch android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Switch" android:id="@+id/Switch" android:layout_below="@+id/Switch" android:layout_alignLeft="@+id/Switch"/>
将是一个有效的开关.