Issue
I am going to want to rounded corners on button like this below code
button.setWidth(buttonWidth);
button.setHeight(buttonHeight);
How to define rounded buttons with java code, no xml
Solution
Use the Material Components for Android.
Just add the dependency:
implementation ‘com.google.android.material:material:1.0.0’
Add the MaterialButton
in your layout:
<com.google.android.material.button.MaterialButton
....
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
app:cornerRadius=".."
app:strokeColor="@color/colorPrimary"/>
and use the method setCornerRadius
.
Something like:
button.setCornerRadius(..);
Answered By - Gabriele Mariotti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.