Issue
I would like to implement the black button from this image taken from material.io which is used to expand the bottom sheet. The content of the button is not important its achieving the one rounded corner. When trying to set the corner radius I only have the ability to round all 4 corners not one individual corner. Could someone please advise how they did this? They dont provide any example of this button on that website.
I have this so far which does not work:
<com.google.android.material.button.MaterialButton
android:id="@+id/btnBottomSheetGratitude"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:insetTop="0dp"
android:insetBottom="0dp"
android:gravity="center_vertical"
android:text="Examples"
android:background="@drawable/btn_bottom_sheet"
app:icon="@drawable/ic_baseline_arrow_drop_up_24"
app:iconPadding="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:topLeftRadius="1000dp" />
<solid android:color="@color/white" />
</shape>
Solution
You can use the shapeAppearanceOverlay
attribute:
<com.google.android.material.button.MaterialButton
android:insetTop="0dp"
android:insetBottom="0dp"
app:shapeAppearanceOverlay="@style/one_rounded"
app:icon="@drawable/ic_add_24px"
app:iconPadding="4dp"
/>
with:
<style name="one_rounded">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeTopLeft">50%</item>
</style>
Answered By - Gabriele Mariotti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.