<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.
Just use material theme .change parent of AppTheme in styles to some material theme like Theme.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>
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"/>
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.