RadioRealButton


Source link: https://github.com/ceryle/RadioRealButton

RadioRealButton

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

Preview






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?

  • Border is now part of the round container layout.
  • android:padding and rest padding attributes were working not as expected. Now, they are fixed.
  • textTypeface attribute now works like button's typeface. You can give your typeface using textTypefacePath attribute.
  • Default scaling value is now 1 as it has to be.
What added?
  • New animations added. There was only a sliding view, but now 4 more added. You can use them with app:selectorAnimationType attribute.
  • enableDeselection attribute is added. With this attribute, you can deselect buttons if you re-click on them.
  • Each button has their own selector (sliding selector has still one) and you can give divider between them.
  • textGravity attribute is added which is actually android:gravity. You can give 3 values which are left, center, right.
What removed?
  • 'image' word is replaced with "drawable" word from all attributes which have them. Reason is everyone is used to 'drawable' word and how I have used ImageView in RadioRealButton is no different than regular drawable which is used in buttons expect animations.
  • rrbg_shadow, rrbg_shadowElevation and its margin attributes are removed. You can use android:elevation attribute.
  • rrbg_enabled is removed. You can use android:enabled attribute.

Customization

Some Attributes

Radio Real Button

Option Name Format Description
drawable integer set drawable to button
drawablePadding dimension set padding between text and drawable
drawableTint color set drawable tint by giving a color code or reference
drawableWidth dimension change drawable's width
drawableHeight dimension change drawable's height
drawableGravity integer set drawable position relative to text
text string set button's text
textColor color change button's text color
textSize dimension change button's text size
textTypeface integer default typefaces offered by android itself
textTypefacePath string give your typeface by giving its path
textFillSpace boolean when enabled, it pushes drawable to edges of the button
textStyle integer default styles offered by android itself
textGravity integer give text gravity(not layout_gravity)
ripple boolean set it true for default ripple
rippleColor color give any color to achieve colorful ripples
backgroundColor color give background color by giving a color code or reference
checked boolean its usage is the same as radio button

Radio Real Button Group

Option Name Format Description
radius integer set radius to make radio real button group rounder
borderSize dimension adds border to group with the given size
borderColor dimension changes border color
backgroundColor color give background color by giving a color code or reference
enableDeselection color enable deselection to un-check a button
dividerSize dimension set divider size for the line between buttons
dividerPadding dimension gives padding to divider's top and bottom
dividerColor color give color code or reference
dividerRadius dimension give dimension to make divider's corners rounder
selectorDividerSize dimension set selector divider size for the line between buttons
selectorDividerPadding dimension gives padding to selector divider's top and bottom
selectorDividerColor color give color code or reference
selectorDividerRadius dimension give dimension to make selector divider's corners rounder
bottomLineColor color set bottom line color
bottomLineSize dimension set bottom line height
bottomLineBringToFront boolean if it is true, it brings bottomLine on top of selector
bottomLineRadius dimension give dimension to make bottomLine's corners rounder
selectorTop boolean align selector to top
selectorBottom boolean align selector to bottom
selectorColor color set color of selector
selectorSize dimension set height of selector
selectorRadius dimension give dimension to make selector's corners rounder
selectorBringToFront boolean if it is true, it brings selector on top of everything
selectorAboveOfBottomLine boolean if it is true, it brings selector above of bottom line
selectorFullSize boolean selector fills space up to button's height
checkedPosition integer check a button by a position number
checkedButton reference check a button by button's unique id
animate boolean set animation on bottom moving view
animateSelector integer gives interpolator to selector
animateSelector_delay integer gives delay to selector's animation when it enters
animateSelector_duration integer animation duration of selector in ms
animateDrawables_scale float adjust drawable's size when it is checked
animateDrawables_enter integer enter animation on drawable when button is checked
animateDrawables_enterDuration integer enter animation duration of drawable in ms
animateDrawables_exit integer exit animation on drawable when other button is checked
animateDrawables_exitDuration integer exit animation duration of drawable in ms
animateTexts_scale float adjust text's size when it is checked
animateTexts_enter integer enter animation on text when button is checked
animateTexts_enterDuration integer enter animation duration of text in ms
animateTexts_exit integer exit animation on text when other button is checked
animateTexts_exitDuration integer exit animation duration of text in ms
animateDrawables_tintColorFrom color initial color for drawable's tint color transition animation
animateDrawables_tintColorTo color final color for drawable's tint color transition animation
animateDrawables_tintColor_duration integer total animation duration of drawable's tint transition in ms
animateTexts_textColorFrom color initial color for text's text color transition animation
animateTexts_textColorTo color final color for text's text color transition animation
animateTexts_textColor_duration integer total 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

Resources

Retractable Toolbar - it is an utility library that gives a retractable effect to your toolbar.

This is an Android project allowing to realize a circular ProgressBar in the simplest way possible.

This is an Android project allowing to realize a circular ImageView in the simplest way possible.

Android Web Server (with NanoHTTPD).

Android library that allows a very easy-compatible Shelf View for smartphone and tablet.

Custom Toast on Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes