Android :类不允许膨胀 android.widget.Switch


<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/general_dts_title"
style="@style/TextAppearance.Compat.Notification.Line2"
android:layout_alignParentBottom="false"
android:layout_alignBottom="@+id/imgToggle"
android:textSize="16sp" />
<Switch
android:id="@+id/imgToggle"
android:layout_width="42dp"
android:layout_height="28dp"
android:layout_gravity="right"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
</RelativeLayout>

状态栏:由以下原因引起:android.view.InflateException:com.dts.dtsxultra:layout/view_notification_sample中的二进制XML文件行#338:不允许膨胀类 android.widget.Switch ...

你能帮忙吗? 我尝试删除背景属性,但它仍然不起作用。

我已经尝试了上面的代码段,但没有给文本视图提供样式,它工作得很好。您面临的错误可能不是因为代码段。

RemoveView 只允许某些布局和小部件膨胀。 android.widget.Switch 如您收到的错误一样,RemoteView 不支持。您可以在此处查看支持的视图列表

相关内容

最新更新