I followed the procedure explained on the link bellow but for some reason the switch is never displayed. I changed the visibility to match my app namespace as suggested in other threads to no avail. The procedure works fine if I try adding Icon's or regular buttons.
Thanks a lot.
I'm running it on a Nexus 4 with Android 4.4.4
How to add a switch to android action bar?
Here is my current xml contents.
/menu/main.xml
<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.example.testapp.MainActivity" >
<item
android:id="@+id/myswitch"
android:title=""
app:showAsAction="always"
android:actionLayout="@layout/switch_layout"
/>
</menu>
/layout/switch_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Switch
android:id="@+id/switchForActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>