nex3z / ToggleButtonGroup

A group of flowable toggle buttons, with multiple / single selection support and button customization.
Apache License 2.0
421 stars 48 forks source link

how to change toggle button when is in checked mode? #11

Closed shokri-navid closed 7 years ago

shokri-navid commented 7 years ago

i want to change back ground of button when user check it. this has a default blue but i want to change it to my custom color? is there any method to set this property or a way to customize button.

nex3z commented 7 years ago

For the built-in CircularToggle and LabelToggle, you can use the tbgMarkerColor attribute to change the color of the marker.

For example, add app:tbgMarkerColor="@android:color/holo_red_light" to every CircularToggle in the demo layout activity_single_select.xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    ...>

    <com.nex3z.togglebuttongroup.SingleSelectToggleGroup
        android:id="@+id/group_choices"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tbgCheckedButton="@+id/choice_a">

        <com.nex3z.togglebuttongroup.button.CircularToggle
            android:id="@+id/choice_a"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16sp"
            android:text="A"
            app:tbgMarkerColor="@android:color/holo_red_light"/>

        ...

    </com.nex3z.togglebuttongroup.SingleSelectToggleGroup>

</LinearLayout>

This will produce:

device-2017-08-08-003905