Search code examples
androidfacebookandroid-fragmentsfacebook-messenger

How to create Facebook Messenger like buttons for MESSENGER\ACTIVE Fragment, and how to swap fragments using them?


I'd like to know how MESSENGER\ACTIVE button configuration is achieved...

And if switching fragments on button click will work with this configuration..?





enter image description here


Solution

  • You can do it by customizing a RadioGroup with two RadioButton as child.

    Here is some hints-

    Steps can be like this

    1. Create a drawable shape of type rectangle in xml with corner and stroke. Use it for the RadioGroup background.
    2. Create selector using the similar shapes (for color as per selected and un-selected one)for two RadioButon and set them as individual background.
    3. Create one color drawable in xml for selected and un-selected states and set its as textColor to the RadioButton
    4. Set android:buttonattribute of RadioButton to null. Here is an example which i have posted as answer to an SO question - How to custom switch button?