ceryle / radiorealbutton Goto Github PK
View Code? Open in Web Editor NEWA custom radio button for Android API 12+
License: Apache License 2.0
A custom radio button for Android API 12+
License: Apache License 2.0
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.soha_web.kamter"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
It seems this library needs further configuration in order to perform normally when it is used in Anko code.
The screenshot shows two radio group under the "Sex" column. The above one is created by using XML layout and the one below is created through Anko. The divider is missing in this case. Also there is no rippling effect when click the radio button. (Not sure if not setting ripple will affect it or not.)
Here is the Anko part for the radio button
radioRealButtonGroup {
dividerColor = Color.BLUE
dividerSize = 200
dividerBackgroundColor = Color.BLUE
selectorSize = 200
selectorColor = Color.BLUE
radius = 200f
customRadioButton {
text = resources.getString(R.string.basic_info_male)
}
customRadioButton {
text = resources.getString(R.string.basic_info_female)
}
}
I want to change the color of radio buttons, but when I apply the color the selected line which I applied disappears. Please help.
Here is the code if you want to look at it:
<co.ceryle.radiorealbutton.RadioRealButtonGroup
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:rrb_backgroundColor="@color/light"
app:rrbg_animateTexts_enter="overshoot"
app:rrbg_bottomLineBringToFront="true"
app:rrbg_radius="10dp"
app:rrbg_selectorColor="@color/action"
app:rrbg_selectorSize="3dp">
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/consumer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@color/action"
app:rrb_text="Consumer"
app:rrb_textColor="@color/action" />
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/vendor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@color/action"
app:rrb_text="Vendor"
app:rrb_textColor="@color/action" />
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/professional"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@color/action"
app:rrb_text="Professional"
app:rrb_textColor="@color/action" />
</co.ceryle.radiorealbutton.RadioRealButtonGroup>
Getting this crash on Android P
java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
at android.graphics.Canvas.checkValidClipOp(Canvas.java:779)
at android.graphics.Canvas.clipPath(Canvas.java:1007)
at co.ceryle.radiorealbutton.RoundedCornerLayout.dispatchDraw(RoundedCornerLayout.java:80)
at android.view.View.buildDrawingCacheImpl(View.java:19472)
at android.view.View.buildDrawingCache(View.java:19338)
at android.view.View.draw(View.java:19927)
at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
at android.view.View.draw(View.java:20210)
at android.view.View.updateDisplayListIfDirty(View.java:19082)
at android.view.View.draw(View.java:19935)
at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
at android.view.View.updateDisplayListIfDirty(View.java:19073)
at android.view.View.draw(View.java:19935)
at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
at android.view.View.updateDisplayListIfDirty(View.java:19073)
at android.view.View.draw(View.java:19935)
at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
at android.view.View.draw(View.java:20210)
at android.support.v4.view.ViewPager.draw(ViewPager.java:2420)
at android.view.View.updateDisplayListIfDirty(View.java:19082)
at android.view.View.draw(View.java:19935)
at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
at android.view.View.draw(View.java:20210)
at android.view.View.updateDisplayListIfDirty(View.java:19082)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290)
at android.view.View.updateDisplayListIfDirty(View.java:19042)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:801)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3312)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3116)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2485)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7184)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Fantastic library, thank you so much.
Looking to apply a long press so that I can display a small tooltip with more information about the icon/radio button - but applying a OnLongClick listener doesn't fire.
Is this possible? My current solution is going to be to show a snackbar
I am trying to run my app in Android 4.1.2 API 16 and i get this problem:
java.lang.RuntimeException: Unable to start activity ComponentInfo{tkskoapps.com.preciodemedicamentos/tkskoapps.com.preciodemedicamentos.ui.activity.MainActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class co.ceryle.radiorealbutton.library.RadioRealButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class co.ceryle.radiorealbutton.library.RadioRealButton
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at tkskoapps.com.preciodemedicamentos.ui.fragment.SearchFragment.onCreateView(SearchFragment.java:82)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at tkskoapps.com.preciodemedicamentos.ui.fragment.SearchFragment.onCreateView(SearchFragment.java:82)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at co.ceryle.radiorealbutton.library.RadioRealButton.updatePadding(RadioRealButton.java:473)
at co.ceryle.radiorealbutton.library.RadioRealButton.updatePaddings(RadioRealButton.java:456)
at co.ceryle.radiorealbutton.library.RadioRealButton.setPadding(RadioRealButton.java:451)
at android.view.View.recomputePadding(View.java:10914)
at android.view.View.resolvePadding(View.java:11584)
at android.view.View.resolveLayoutDirection(View.java:11524)
at android.view.View.getResolvedLayoutDirection(View.java:5708)
at android.view.View.requestLayout(View.java:15125)
at android.view.View.setLayoutParams(View.java:9904)
at co.ceryle.radiorealbutton.library.RadioRealBu
What can i do? It works fine on ANdroid 5, 6, 7 but i am having problems with API 16.
thanks!
icannot change button text color programmatically ..not working
icannot change RadioRealGroup height Or RadioRealButton height ..not working
Code used :
<co.ceryle.radiorealbutton.RadioRealButtonGroup
android:id="@+id/answerRadioButtonGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:elevation="2dp"
app:rrbg_animateTexts_enter="overshoot"
app:rrbg_animateTexts_scale="2"
app:rrbg_animateTexts_textColorFrom="@android:color/black"
app:rrbg_animateTexts_textColorTo="@color/white"
app:rrbg_backgroundColor="@color/white"
app:rrbg_dividerColor="@android:color/black"
app:rrbg_dividerPadding="10dp"
app:rrbg_dividerRadius="0dp"
app:rrbg_dividerSize="1dp"
app:rrbg_selectorAboveOfBottomLine="true"
app:rrbg_selectorColor="#2196F3"
app:rrbg_selectorFullSize="true"
app:rrbg_selectorSize="4dp">
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/radioButtonA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@android:color/black"
app:rrb_text="A"
app:rrb_textColor="@android:color/black" />
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/radioButtonB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@android:color/black"
app:rrb_text="B"
app:rrb_textColor="@android:color/black" />
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/radioButtonC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@android:color/black"
app:rrb_text="C"
app:rrb_textColor="@android:color/black" />
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/radioButtonD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@android:color/black"
app:rrb_text="D"
app:rrb_textColor="@android:color/black" />
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/radioButtonE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_ripple="true"
app:rrb_rippleColor="@android:color/black"
app:rrb_text="E"
app:rrb_textColor="@android:color/black" />
</co.ceryle.radiorealbutton.RadioRealButtonGroup>
This is a part of a fragment inside a ViewPager. On device rotation, the selected option becomes -1, but the selector remains on the option selected previously. Here is a video of the same : http://kungfucat.me/images/temporaryAttachment.mp4
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.example, PID: 25825
java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
suggestion : you need to replace canvas.clipPath(path, Region.Op.REPLACE); with canvas.clipPath(path);
optional: try to upgrade it to androidx
Continuing improvement related to #24 it could be useful to have the previous position on change listeners. Like onPositionChanged(RadioRealButton button, int from, int to)
We then have the ability the change to color of the selected item and then restore it to its previous color when some other item is selected.
Hey,
thank you for your great library.
I have a problem with the Radio Group.
I cant see or use the checkedPosition or checkedButton method.
They just dont show up?
private RadioRealButtonGroup radioRealButtonGroup
radioRealButtonGroup = findViewById(R.id.real_readio_button_category);
And these to methods are just red and not found ( I know that checkedButton needs a reference, just for demo purpose no one included here)
radioRealButtonGroup.checkedPosition(2);
radioRealButtonGroup.checkedButton();
I want to add more radioButton when the app is running.
Can I add radioButton programmatically?
I need a ButtonGroup with three buttons in the first row and two in the second.
How would I implement this?
If I put a LinearLayout inside of the ButtonGroup, the buttons stop being clickable.
First of all thank you ceryle, for making very nice & useful library. I have used this library in my one project which was version 1.4.9, that was working very good. But recently i have added 2.1.0 version but it is showing this error
Error:(49, 13) Failed to resolve: com.github.ceryle:RadioRealButton:v2.1.0 Show in File Show in Project Structure dialog
if I change it to 1.4.9 then its work good and don's show any error.
Hi,
the selector line always show under the second button, when i choose the first button, the selector line just fill the whole button group instead of moving to the first button.
here is my code:
<co.ceryle.radiorealbutton.library.RadioRealButtonGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:rrbg_bottomLineSize="0dp"
app:rrbg_dividerColor="@color/black"
app:rrbg_dividerSize="1dp"
app:rrbg_selectorColor="@color/colorFAB1"
app:rrbg_selectorSize="3dp"
app:rrbg_radius="10dp"
app:rrbg_shadow="true"
app:rrbg_shadowElevation="2dp"
app:rrbg_shadowMargin="3dp"
app:rrbg_selectorAboveOfBottomLine="true"
app:rrbg_position="1"
app:rrbg_animateTexts_enter="bounce"
app:rrbg_animateImages_enter="bounce"
app:rrbg_animateImages_enterDuration="500"
app:rrbg_animateImages_exit="overshoot"
app:rrbg_animateTexts_exit="overshoot"
app:rrbg_animateImages_exitDuration="1500"
app:rrbg_animateSelector="bounce">
<co.ceryle.radiorealbutton.library.RadioRealButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_image="@drawable/male_48"
app:rrb_imageHeight="15dp"
app:rrb_imageWidth="15dp"
app:rrb_text="Male" />
<co.ceryle.radiorealbutton.library.RadioRealButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_image="@drawable/female_48"
app:rrb_imageHeight="15dp"
app:rrb_imageWidth="15dp"
app:rrb_text="Female" />
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
I tried taking the sample app and changing the RadioRealButtonGroup background color with app:rrbg_backgroundColor="@color/black"
, but it doesn't change.
I'm on a Nexus 5X Android 7.1.
Hi.
Firstly I want to thank and congratulate you for the library. Very good work!
Now, the problem. I need to change the selected button during the execution of the code. I'm trying to use the setSelected method, but it only works on the onCreate, the first time I call it. Am I doing something wrong ?
Hello,
Thank you very much for adding gravity to the views ;)
But with the 2.0.0 version, you deleted rrbg_ suffix to your attributes, so I've got "Attribute "rippleColor" has already been defined" error at build time for example.
Is it possible to rollback to previous suffix, or tell me how to deal with this problem?
Thanks,
Lionel
On your page you must update the compile line to
compile 'com.github.ceryle:RadioRealButton:v2.0.4'
When I'm using the v2.0.2 the setPosition() is working but the selector is not working
Hi,
I have one Button inside the ButtonGroup. Deselection is disabled.
If I click it for a second time, the checked state is set to false (Line 515 of RadioRealButtonGroup).
Afterwards, a programmatical deselection is not possible because of the state change...
A fix would be to add the condition "buttonIn != buttonOut" to the if branch in Line 514.
Cheers, Arty.
Hi ,
How can i change image on selection?
Hi
My application support multi localization and when the application is turned to right to left localization and try to select any button but not the first one then selector move to right so it disappears and no button is being selected.
EX: In the previous image "Button 2" is selected.
You have to check the current local if it was right to left you could reflect the selector move to be from right to left
Thanks
When trying to get a full height permanent selection using app:rrbg_selectorFullSize="true" text is visible but the images aren't shown. Is there a different way to not have the underline, but have the background change on the selected item?
Hi ceryle, great lib! I love it.
It would be useful to be able to add a simple border (with radius, like now) instead of a shadow. I'm using RadioRealButton inside another card and it doesn't look great with the shadow.
Thanks :)
I have a NestedScrollView as my root layout and a RelativeLayout which contains some editext above 2 radioRealButtonGroup. I've placed them below an editText using "layout__below" but whenever my editText grows in size the actual selected button in both buttons group makes both the vector icon and the label text bigger .
TL;DR every time a line is added to the editText the icon and the label grows by some X amount (apparently without limit).
Putting both the button groups into another RelativeLayout solves the problem
Hey there,
I'm new on Android and GitHub. I 'm still working on my Android project, I want to publish on Play Store.
I want to ask:
Please answer to me, that's important to me..
When you select a radio button, the text size increases, and it then decreases when you select another button.
It look like there isn't a default size for the non-selected text, and that it increases/decreases by percent. Therefore it is possible to rapidly select a radio button then another many times, and the text will shrink or get bigger and stay like that.
I can provide a picture if needed.
Hello,
First of all, your library is great!
Is it possible to implement the setEnabled(boolean), in order to enable or disable the group?
Thanks,
Lionel
Hi, great widget here !
Just found one small bug, when using vector as button images there are artefacts after the growing upon selection. It is not related to xml vector size as they are far bigger than what is displayed and without issue outside of this case.
Hello and thank you very much for your cool library!
Adding a drawable image is easy, and adding text is easy, but I cannot find a way to include them both inside a single radio button
My code I'm experimenting with:
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/radioTagCoffee"
app:rrb_ripple="true"
app:rrb_backgroundColor="@color/gender_icon_color_transparent"
app:rrb_rippleColor="#DCDCDC"
app:rrb_drawable="@drawable/tag_coffee"
app:rrb_drawableHeight="@dimen/gender_icon_height"
app:rrb_textColor="@color/black"
app:rrb_textFillSpace="true"
app:rrb_text="ssgsgsgs"
app:rrb_drawablePadding="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Thanks in advance
I am trying to set one radio button checked as default. I used android:checked="true" on radio button, and android:checkedButton="@id/button1" in radiogroup; but none of them work.
Can you please add or describe how to default check a radio button?
Thanks!
On screens of different sizes, the text doesn't look big enough.
Is this missing or am I missing something
`
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<co.ceryle.radiorealbutton.library.RadioRealButtonGroup
android:id="@+id/radioGroupBtnMatcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:rrbg_animateDrawables_enter="overshoot"
app:rrbg_animateTexts_enter="overshoot"
app:rrbg_dividerColor="@color/colorAccent"
app:rrbg_dividerSize="1dp"
app:rrbg_selectorColor="@color/colorPrimaryDark"
app:rrbg_selectorSize="6dp">
<co.ceryle.radiorealbutton.library.RadioRealButton
android:id="@+id/btnRadioOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="15dp">
<ImageView
android:id="@+id/imageFirst"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp" />
<TextView
android:id="@+id/nameFirst"
android:layout_width="115dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:text="line 1"
android:textColor="@android:color/black"
android:textSize="9dp"
android:textStyle="bold" />
</co.ceryle.radiorealbutton.library.RadioRealButton>
<co.ceryle.radiorealbutton.library.RadioRealButton
android:id="@+id/btnRadioTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:id="@+id/imageSecond"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginBottom="3dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="3dp" />
<TextView
android:id="@+id/nameSecond"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="line 1"
android:textColor="@android:color/black"
android:textSize="9dp"
android:textStyle="bold" />
</co.ceryle.radiorealbutton.library.RadioRealButton>
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
</RelativeLayout>
</android.support.v7.widget.CardView>`
I use recyclerView. So I can't get TextView value and ImageView url. How do it?
btns.setOnClickedButtonListener(new RadioRealButtonGroup.OnClickedButtonListener() { @Override public void onClickedButton(RadioRealButton button, int position) { Log.i("AlDAA", "OnClick"); Toast.makeText(MatchAdapter.context, "Clicked: "+position+" "+button, Toast.LENGTH_SHORT).show(); } });
this is not working :( 👎
I'm want to set setAnimateTextsEnter
programmatically. But I do not know what is the int
I should pass to the method!
Could someone please help. Where should I get this int
value !
Hi,
I didn't see a way to deselect all buttons in RadioRealButtonGroup. Also the RadioRealButton view doesn't have setChecked(boolean) method, so I can't go through all of the buttons in the group and deselect them. Do you intend to change this any time soon?
Thank you for your time :)
Hello,
Firstly thanks for this great library. I would like to deselect selected item programmatically. I tried to use deselect() method but it didn't work. How can I do that?
I tried using the example code at the bottom of the page to test it out. But I'm getting this error whenever I put the java code in. Otherwise the XML part works fine. But the minute I put the java code the function setOnClickedButtonListener and OnPositionChangedListener just causes the app to crash.
Main Activity
package com.masslabs.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import co.ceryle.radiorealbutton.RadioRealButton;
import co.ceryle.radiorealbutton.RadioRealButtonGroup;
public class MainActivity extends AppCompatActivity {
final RadioRealButton button1 = (RadioRealButton) findViewById(R.id.button1);
final RadioRealButton button2 = (RadioRealButton) findViewById(R.id.button2);
RadioRealButtonGroup group = (RadioRealButtonGroup) findViewById(R.id.group);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 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! Butten: " + button.getText(), 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 currentPosition, int lastPosition) {
Toast.makeText(MainActivity.this, "Button Changed! Text: " + button.getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
XML File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<co.ceryle.radiorealbutton.RadioRealButtonGroup
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:rrbg_animateDrawables_enter="overshoot"
app:rrbg_animateTexts_enter="overshoot"
app:rrbg_dividerColor="@android:color/black"
app:rrbg_dividerSize="1dp"
app:rrbg_radius="10dp"
app:rrbg_selectorColor="@android:color/holo_red_dark"
app:rrbg_selectorSize="6dp">
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/button1"
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="@android:color/black"
app:rrb_text="Button 1"
app:rrb_textColor="@android:color/black"/>
<co.ceryle.radiorealbutton.RadioRealButton
android:id="@+id/button2"
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="@android:color/black"
app:rrb_text="Button 2"
app:rrb_textColor="@android:color/black"/>
</co.ceryle.radiorealbutton.RadioRealButtonGroup>
</LinearLayout>
Hi,
i updated to your newest version 2.0.2 and now have the weird problem that the selector position won't be updated after i set the position programmatically. The current position of the button group is correctly set and i can't click the setted button but the selector is still on the old position. It's weird because i tried your sample app which works fine. I did some debugging, but couldn't really find anything. I also put the setPosition command in a rxandroid observable to make sure that it gets executed on the main thread.
Hope you can help me.
Here is my XML code:
<co.ceryle.radiorealbutton.library.RadioRealButtonGroup android:id="@+id/btnSelfAssessment" android:layout_width="match_parent" android:layout_height="wrap_content" app:rrbg_dividerColor="@color/seperator" app:rrbg_dividerSize="1dp" app:rrbg_selectorColor="@color/colorAccent" app:rrbg_selectorSize="6dp" app:rrbg_radius="10dp" app:rrbg_borderSize="2dp" app:rrbg_borderColor="@color/seperator" app:rrbg_checkedPosition="0"> <co.ceryle.radiorealbutton.library.RadioRealButton android:layout_width="wrap_content" android:layout_height="wrap_content" app:rrb_ripple="true" app:rrb_rippleColor="@color/colorAccent" app:rrb_text="@string/btn_beginner" app:rrb_textSize="16dp" app:rrb_textColor="@android:color/black"/> <co.ceryle.radiorealbutton.library.RadioRealButton android:layout_width="wrap_content" android:layout_height="wrap_content" app:rrb_ripple="true" app:rrb_rippleColor="@color/colorAccent" app:rrb_text="@string/btn_advanced" app:rrb_textSize="16dp" app:rrb_textColor="@android:color/black"/> <co.ceryle.radiorealbutton.library.RadioRealButton android:layout_width="wrap_content" android:layout_height="wrap_content" app:rrb_ripple="true" app:rrb_rippleColor="@color/colorAccent" app:rrb_text="@string/btn_expert" app:rrb_textSize="16dp" app:rrb_textColor="@android:color/black"/> </co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
What would be the best way to get one selector color per item ?
As the selector move with animation for one item to another I trying to find a way to change it in the middle of the animation or something like this
Hi, how can I remove de bottom line?
I am using this library to create radio buttons. My layout works on all the api levels up to api 28. But it give the following error on api 29.
Error:
java.lang.IllegalArgumentException Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
Please resolve this issue, I am using the latest version of your library.
Thanks
rippleColor has no effect.
<co.ceryle.radiorealbutton.library.RadioRealButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rrb_backgroundColor="@color/transparent"
app:rrb_ripple="true"
app:rrb_rippleColor="@color/aqua_blue"
app:rrb_text="Private"
app:rrb_textColor="@color/white"/>
Hi I am trying to change the selected button color but with no success
color_selector.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/color_white" android:state_selected="true" /> <item android:color="@android:color/black" /> </selector>
and this is my radio button
<co.ceryle.radiorealbutton.RadioRealButton android:layout_width="0dp" android:layout_height="wrap_content" android:weightSum="1" app:rrb_textColor="@color/color_selector" app:rrb_text="FAN" />
I can't configure targetSdkVersion 28 with this library. Could you uptdate?
thank you.
Code:
RadioRealButtonGroup buttonGroup = (RadioRealButtonGroup) findViewById(R.id.rrbg);
buttonGroup.setOnPositionChangedListener(new RadioRealButtonGroup.OnPositionChangedListener() {
@Override
public void onPositionChanged(RadioRealButton button, int position) {
Log.v("DEBUG", "Button clicked: " + position);
}
});
01-18 14:47:37.404 31987-31987/com.[redacted]
E/UncaughtException: java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
at java.util.ArrayList.get(ArrayList.java:310)
at co.ceryle.radiorealbutton.library.RadioRealButtonGroup.setPosition(RadioRealButtonGroup.java:399)
at co.ceryle.radiorealbutton.library.RadioRealButtonGroup.onLayout(RadioRealButtonGroup.java:376)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
....
There's a lot more to the trace if you need it.
One problem that I have today is: If I put a code that is a little bit slow, inside the radioGroup listener, the button position only changes when the processing finishes. This is very awkward when it comes to user experience. Could you change the button position before anything?
radioGroup.setOnClickedButtonListener(RadioRealButtonGroup.OnClickedButtonListener {
button, position ->
if(position != currentPosition) {
when (button) {
ratingButton -> {
playersInFastAdapter.clear()
playersRating?.forEach {
playersInFastAdapter.add(PlayerListRankingComplete(this, it, App.CARD_RANKING_RATING_LIST))
}
}
}
How to make a button with only text with top and bottom padding?
I have noticed that calling deselect() deselects any selected value as expected. However, if it is called again, the radio button that was last selected is re-selected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.