0

I want to style a ToggleButton that I placed in my ActionBar but I can't seem to do so. I have tried to apply a simple background to it but that doesn't seem to work. I tried to follow this: Android toggle button custom look but that didn't seem to work Here was my attempt:

create_post_menu.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=".CreatePost">

    <item
        android:id="@+id/toggle_test"
        android:title="Private"
        app:showAsAction="always"
        android:orderInCategory="1"
        android:background="@drawable/pick_out_line"
        app:actionViewClass="android.widget.ToggleButton" />
</menu>

pick_out_line.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/white" android:state_checked="true" />
    <item android:drawable="@color/white" android:state_pressed="true" />
    <item android:drawable="@color/colorPrimary" />
</selector>
Community
  • 1
  • 1
user1871869
  • 3,317
  • 13
  • 56
  • 106

1 Answers1

2

You can refer to this question : ToggleButtons as actionBar custom view behaving weirdly. Maybe it can help you for resolve your issue is custion toggle button when setup action bar

Community
  • 1
  • 1
Khoa Tran
  • 528
  • 6
  • 18