<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.
-
give some height and width to your buttonSandeep dhiman– Sandeep dhiman2019年12月03日 04:43:48 +00:00Commented Dec 3, 2019 at 4:43
-
You can write style for thisArnold Brown– Arnold Brown2019年12月03日 06:19:17 +00:00Commented Dec 3, 2019 at 6:19
3 Answers 3
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>
1 Comment
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"/>
Comments
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
1 Comment
Explore related questions
See similar questions with these tags.