I need to put Switch inside item in navigation drawer. I\'m using new design support library, but I cannot find if it is posibble at all. When using
android
For those of you using Kotlin Extensions
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/nav_notifications_switch"
android:icon="@drawable/ic_notifications"
android:title="@string/notifications"
app:actionLayout="@layout/drawer_notifications_switch" />
</menu>
<Switch xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toggleSwitch"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
nav_view.menu.findItem(R.id.nav_notifications_switch)
.actionView
.toggleSwitch
.setOnCheckedChangeListener { _, isChecked ->
}
You should be able to.
Your navigation drawer view can be a LinearLayout
, and inside that, you can include your NavigationView
and another ViewGroup
adding the switches.