Home

Awesome

Android Arsenal

Archived

I stopped developing this library for a long time ago. I thought about revising it recently but I think there is no need for it anymore due to Jetpack Compose. As an alternative to this, I recommend you to use this library made with Jetpack Compose by Zack Klippenstein: https://gist.github.com/zach-klippenstein/7ae8874db304f957d6bb91263e292117

Thank you all for your support.

RadioRealButton

poster

Radio Real Button is a substitute of the Radio Button. Its purpose is to give more elegant view for Android users.

Preview

1 <br /> 2 <br /> 3a 3b <br /> 4 <br /> 5 <br /> 6

Installation

Gradle

Add it to your build.gradle with:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

and:

dependencies {
    compile 'com.github.ceryle:RadioRealButton:v2.1.1'
}

What has changed with version 2?

What added?
What removed?

Customization

Some Attributes

Radio Real Button

Option NameFormatDescription
drawableintegerset drawable to button
drawablePaddingdimensionset padding between text and drawable
drawableTintcolorset drawable tint by giving a color code or reference
drawableWidthdimensionchange drawable's width
drawableHeightdimensionchange drawable's height
drawableGravityintegerset drawable position relative to text
textstringset button's text
textColorcolorchange button's text color
textSizedimensionchange button's text size
textTypefaceintegerdefault typefaces offered by android itself
textTypefacePathstringgive your typeface by giving its path
textFillSpacebooleanwhen enabled, it pushes drawable to edges of the button
textStyleintegerdefault styles offered by android itself
textGravityintegergive text gravity(not layout_gravity)
ripplebooleanset it true for default ripple
rippleColorcolorgive any color to achieve colorful ripples
backgroundColorcolorgive background color by giving a color code or reference
checkedbooleanits usage is the same as radio button

Radio Real Button Group

Option NameFormatDescription
radiusintegerset radius to make radio real button group rounder
borderSizedimensionadds border to group with the given size
borderColordimensionchanges border color
backgroundColorcolorgive background color by giving a color code or reference
enableDeselectioncolorenable deselection to un-check a button
dividerSizedimensionset divider size for the line between buttons
dividerPaddingdimensiongives padding to divider's top and bottom
dividerColorcolorgive color code or reference
dividerRadiusdimensiongive dimension to make divider's corners rounder
selectorDividerSizedimensionset selector divider size for the line between buttons
selectorDividerPaddingdimensiongives padding to selector divider's top and bottom
selectorDividerColorcolorgive color code or reference
selectorDividerRadiusdimensiongive dimension to make selector divider's corners rounder
bottomLineColorcolorset bottom line color
bottomLineSizedimensionset bottom line height
bottomLineBringToFrontbooleanif it is true, it brings bottomLine on top of selector
bottomLineRadiusdimensiongive dimension to make bottomLine's corners rounder
selectorTopbooleanalign selector to top
selectorBottombooleanalign selector to bottom
selectorColorcolorset color of selector
selectorSizedimensionset height of selector
selectorRadiusdimensiongive dimension to make selector's corners rounder
selectorBringToFrontbooleanif it is true, it brings selector on top of everything
selectorAboveOfBottomLinebooleanif it is true, it brings selector above of bottom line
selectorFullSizebooleanselector fills space up to button's height
checkedPositionintegercheck a button by a position number
checkedButtonreferencecheck a button by button's unique id
animatebooleanset animation on bottom moving view
animateSelectorintegergives interpolator to selector
animateSelector_delayintegergives delay to selector's animation when it enters
animateSelector_durationintegeranimation duration of selector in ms
animateDrawables_scalefloatadjust drawable's size when it is checked
animateDrawables_enterintegerenter animation on drawable when button is checked
animateDrawables_enterDurationintegerenter animation duration of drawable in ms
animateDrawables_exitintegerexit animation on drawable when other button is checked
animateDrawables_exitDurationintegerexit animation duration of drawable in ms
animateTexts_scalefloatadjust text's size when it is checked
animateTexts_enterintegerenter animation on text when button is checked
animateTexts_enterDurationintegerenter animation duration of text in ms
animateTexts_exitintegerexit animation on text when other button is checked
animateTexts_exitDurationintegerexit animation duration of text in ms
animateDrawables_tintColorFromcolorinitial color for drawable's tint color transition animation
animateDrawables_tintColorTocolorfinal color for drawable's tint color transition animation
animateDrawables_tintColor_durationintegertotal animation duration of drawable's tint transition in ms
animateTexts_textColorFromcolorinitial color for text's text color transition animation
animateTexts_textColorTocolorfinal color for text's text color transition animation
animateTexts_textColor_durationintegertotal animation duration of text's text color in ms

Examples

In Xml Layout
<co.ceryle.radiorealbutton.RadioRealButtonGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:rrbg_animateDrawables_enter="overshoot"
    app:rrbg_animateTexts_enter="overshoot"
    app:rrbg_dividerColor="@color/black"
    app:rrbg_dividerSize="1dp"
    app:rrbg_radius="10dp"
    app:rrbg_selectorColor="@color/red_700"
    app:rrbg_selectorSize="6dp">

    <co.ceryle.radiorealbutton.RadioRealButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:rrb_drawable="@mipmap/ic_launcher"
        app:rrb_drawableHeight="36dp"
        app:rrb_drawablePadding="8dp"
        app:rrb_drawableWidth="36dp"
        app:rrb_ripple="true"
        app:rrb_rippleColor="@color/black"
        app:rrb_text="Button 1"
        app:rrb_textColor="@color/black"/>

    <co.ceryle.radiorealbutton.RadioRealButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:rrb_drawable="@mipmap/ic_launcher"
        app:rrb_drawableGravity="right"
        app:rrb_drawableHeight="36dp"
        app:rrb_drawablePadding="8dp"
        app:rrb_drawableWidth="36dp"
        app:rrb_ripple="true"
        app:rrb_rippleColor="@color/black"
        app:rrb_text="Button 2"
        app:rrb_textColor="@color/black"/>
</co.ceryle.radiorealbutton.RadioRealButtonGroup>
Listener Example
final RadioRealButton button1 = (RadioRealButton) findViewById(R.id.button1);
final RadioRealButton button2 = (RadioRealButton) findViewById(R.id.button2);

RadioRealButtonGroup group = (RadioRealButtonGroup) findViewById(R.id.group);

// onClickButton listener detects any click performed on buttons by touch
group.setOnClickedButtonListener(new RadioRealButtonGroup.OnClickedButtonListener() {
    @Override
    public void onClickedButton(RadioRealButton button, int position) {
        Toast.makeText(MainActivity.this, "Clicked! Position: " + position, Toast.LENGTH_SHORT).show();
    }
});

// onPositionChanged listener detects if there is any change in position
group.setOnPositionChangedListener(new RadioRealButtonGroup.OnPositionChangedListener() {
    @Override
    public void onPositionChanged(RadioRealButton button, int position) {
        Toast.makeText(MainActivity.this, "Position Changed! Position: " + position, Toast.LENGTH_SHORT).show();
    }
});

// onLongClickedButton detects long clicks which are made on any button in group.
// return true if you only want to detect long click, nothing else
// return false if you want to detect long click and change position when you release
group.setOnLongClickedButtonListener(new RadioRealButtonGroup.OnLongClickedButtonListener() {
    @Override
    public boolean onLongClickedButton(RadioRealButton button, int position) {
        Toast.makeText(MainActivity.this, "Long Clicked! Position: " + position, Toast.LENGTH_SHORT).show();
        return false;
    }
});

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE.md file for details