Android Question Is possible to make a button with different corner radius?

asales

Well-Known Member
Licensed User
I see this code of @klaus that make a panel with diferent corner radius:
https://www.b4x.com/android/forum/t...th-different-corner-radius.51475/#post-322392

and this code of @Erel that make a label:
https://www.b4x.com/android/forum/t...us-curves-on-one-side-only.35070/#post-205487

Is possible to make a button with different corner radius?

I try this codes but I get this error in Button view:
B4X:
java.lang.RuntimeException: Method: setCornerRadii not found in: android.graphics.drawable.StateListDrawable
 

NJDude

Expert
Licensed User
I could be wrong but Klaus' code doesn't work on newer versions of Android.
 
Last edited:
Upvote 0

asales

Well-Known Member
Licensed User
I test both codes in Android 4.4 and 7.0.
It works fine to labels and panels, but not to buttons.

In Android 4.4 I get this error:
B4X:
java.lang.RuntimeException: Method: setCornerRadii not found in: android.graphics.drawable.StateListDrawable
and in Android 7.0 I get this error:
B4X:
java.lang.RuntimeException: Method: setCornerRadii not found in: android.graphics.drawable.RippleDrawable
 
Upvote 0

nibbo

Active Member
Licensed User
Hi, sorry to resurrect this old thread but I think it best if the answer was in this thread.

Yes. You need to create a StateListDrawable and set the corners radius of each of the drawables that are inside the StateListDrawable.

Could someone clarify how this is done?
Please note that this is to be applied to labels which are generated at run time not created in the designer.
Thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Upvote 0

DonManfred

Expert
Licensed User
https://www.b4x.com/android/forum/threads/forum-guidelines.55632/

Tips:
  • Post in the correct sub-forum.
  • Use
    B4X:
    code here...
    tags when posting code.
  • All questions should be open to all members.
  • Start a new thread for your question instead of posting in an existing thread.
  • Use the Like button as a gratitude for other members who try to help you.
  • The thread title should summarize the question.
  • Use the search tool.
 
Upvote 0
Top