I'm trying to use a SwitchCompat
widget on the overflow menu of android.support.v7.widget.Toolbar
but I just can't get it to work, it always appears blank.
Here is my menu definition:
<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"
tools:context="com.oveflowtest.ScrollingActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never"/>
<item android:id="@+id/test"
app:actionLayout="@layout/testlayout"
app:showAsAction="never"/>
</menu>
And here is testlayout
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SwitchCompat
android:layout_width="match_parent"
android:layout_height="match_parent" android:text="test"/>
</LinearLayout>
Also if I change showAsAction
to always
instead of never
then it shows just fine on the toolbar but I don't want it there, I want it on the overflow menu that opens up when I press the 3 dots.
I know there is an option to use a checkmark but the design I'm following calls for a switch.
Thanks.