6
<com.google.android.material.button.MaterialButton
 android:id="@+id/button_tour"
 app:cornerRadius="20dp"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_marginHorizontal="30dp"
 android:layout_gravity="center_horizontal"
 android:text="Take a tour"/>

I added a material button in my android project, when i try to set round corner using app:cornerRadius, i find it doesn't work at all.

Gabriele Mariotti
370k114 gold badges1k silver badges937 bronze badges
asked Dec 3, 2019 at 3:39
2
  • give some height and width to your button Commented Dec 3, 2019 at 4:43
  • You can write style for this Commented Dec 3, 2019 at 6:19

3 Answers 3

7

Just use material theme .change parent of AppTheme in styles to some material theme likeTheme.MaterialComponents.Light.NoActionBar.because material components require a material theme.

 <style name="AppTheme.Clinic" parent="Theme.MaterialComponents.Light.NoActionBar">
 <item name="colorPrimary">@color/colorPrimary</item>
 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
 <item name="colorAccent">@color/colorAccent</item>
</style>
answered Dec 3, 2019 at 5:40
Sign up to request clarification or add additional context in comments.

1 Comment

That works! Thank you so much! It has confused me a whole day.
0

Try this: add this style for outline material button

 <style name="materialButtonOutlinedStyle" parent="@style/Widget.MaterialComponents.Button.OutlinedButton">
 <item name="cornerRadius">10dp</item>
</style>

then add this style to your button:

 <com.google.android.material.button.MaterialButton
 android:id="@+id/button_tour"
 style="@style/Widget.MaterialComponents.CardView"
 app:cornerRadius="20dp"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_marginHorizontal="30dp"
 android:layout_gravity="center_horizontal"
 android:text="Take a tour"/>
answered Jul 7, 2022 at 14:12

Comments

-2

Create a new drawable source such as follows

<shape android:shape="rectangle">
 <corners android:radius="20dp" />
</shape>

and set it as background to your MaterialButton

answered Dec 3, 2019 at 5:53

1 Comment

The question is about MaterialButton - this answer is for classic Android Button

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.