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

StatusBar: Caused by: android.view.InflateException: Binary XML file line #338 in com.dts.dtsxultra:layout/view_notification_sample: Class not allowed to be inflated android.widget.Switch ...

Could you please help. I tried removing background attribute, but still it is not working.

2 Answers2

0

I have tried the above piece of code, without giving the style to the textview, it works great. The error that you are facing may not be because of the piece of code.

ACR
  • 317
  • 1
  • 8
0

RemoveView only allows some layout and widget to inflate. android.widget.Switch as in the error you are getting is not supported by RemoteView. You can see the list of supported views here