Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round corners not working #8

Closed
vvavepacket opened this issue Feb 20, 2020 · 6 comments
Closed

round corners not working #8

vvavepacket opened this issue Feb 20, 2020 · 6 comments

Comments

@vvavepacket
Copy link

vvavepacket commented Feb 20, 2020

Hello,

I tried to follow the tutorial as per the medium comment here . But still I'm not getting round corners. I made sure I extended the BottomSheetDialog thru my xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme.BottomSheet" parent="Theme.MaterialComponents.DayNight" />

    <style name="AppTheme.BottomSheet.Themed" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <!-- Global color attributes -->
        <item name="colorPrimary">@color/color_primary</item>
        <item name="colorPrimaryVariant">@color/color_primary_variant</item>
        <item name="colorOnPrimary">@color/color_on_primary</item>
        <item name="colorSecondary">@color/color_secondary</item>
        <item name="colorSecondaryVariant">@color/color_secondary_variant</item>
        <item name="colorOnSecondary">@color/color_on_secondary</item>
        <item name="colorError">@color/color_error</item>
        <item name="colorOnError">@color/color_on_error</item>
        <item name="colorSurface">@color/color_surface</item>
        <item name="colorOnSurface">@color/color_on_surface</item>
        <item name="android:colorBackground">@color/color_background</item>
        <item name="colorOnBackground">@color/color_on_background</item>
        <item name="android:statusBarColor">@color/color_status_bar</item>
        <!-- Global type attributes -->
        <item name="fontFamily">@font/roboto_mono</item>
        <item name="android:fontFamily">@font/roboto_mono</item>
        <!-- Global shape attributes -->
        <item name="shapeAppearanceSmallComponent">@style/AppShapeAppearance.SmallComponent</item>
        <item name="shapeAppearanceMediumComponent">@style/AppShapeAppearance.MediumComponent</item>
        <item name="shapeAppearanceLargeComponent">@style/AppShapeAppearance.LargeComponent</item>
        <!-- Bottom Sheet widget style attributes -->
        <item name="bottomSheetStyle">@style/AppStandardBottomSheet</item>
        <item name="bottomSheetDialogTheme">@style/AppModalBottomSheet</item>
    </style>

    <style name="AppStandardBottomSheet">
        <item name="shapeAppearance">?attr/shapeAppearanceLargeComponent</item>
        <item name="backgroundTint">?attr/colorSecondary</item>
        <item name="android:elevation">8dp</item>
        <item name="behavior_hideable">false</item>
        <item name="behavior_draggable">true</item>
        <item name="behavior_skipCollapsed">false</item>
        <item name="behavior_peekHeight">80dp</item>
        <item name="behavior_fitToContents">false</item>
        <item name="behavior_halfExpandedRatio">0.5</item>
        <item name="behavior_expandedOffset">0</item>
    </style>

    <style name="AppModalBottomSheet" parent="ThemeOverlay.MaterialComponents.DayNight.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/ModalBottomSheet</item>
    </style>

    <style name="ModalBottomSheet" parent="Widget.MaterialComponents.BottomSheet.Modal">
        <!-- Apply attributes here -->
    </style>
</resources>

But still, I'm not seeing the round corners

image

@paulnicolet
Copy link

I can't manage to make rounded corners either. Any additional insights ?

@hmoreau94
Copy link

hmoreau94 commented Apr 10, 2020

Have been trying for a while as well and can't figure it out ... Please give us some help. I downloaded your project, updated style.xml to

<style name="AppShapeAppearance.LargeComponent" parent="ShapeAppearance.MaterialComponents.LargeComponent"> <item name="cornerFamily">rounded</item> <item name="cornerRadius">14dp</item> </style>

The result is that the Standard Bottom Sheet has no effect on its radius whatsoever (cf. screenshot)
Screenshot_2020-04-10-10-55-38-376_com ricknout mdctheming

@ricknout
Copy link
Owner

ricknout commented Apr 10, 2020

In order for me to help diagnose the problem(s), I will need to see some code from the layout.

My suspicion is that the style="?attr/bottomSheetStyle line is missing, eg:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    ...
    <FrameLayout
        android:id="@+id/bottomSheet"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="?attr/bottomSheetStyle"
        app:layout_behavior="@string/bottom_sheet_behavior">
        <!-- Bottom sheet contents -->
    </FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@paulnicolet
Copy link

Hey @ricknout
After some investigation, I have found that the bottom sheet corners are rounded, but the content is not clipped to its bounds, which covers the sheet completely, and hide the rounded corner.
Here is a toy layout as an example:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    ...
    <FrameLayout
        android:id="@+id/bottomSheet"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="?attr/bottomSheetStyle"
        app:layout_behavior="@string/bottom_sheet_behavior">
           
             <View
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:background="@android:color/black"/>

    </FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

In this example, what I get is a completely black bottom sheet, with no rounded corner. Whereas if I set the inner view background to transaparent, I can see the rounded corners.

Any idea how to clip the content ? I have been trying to play with clipChildren without success.

Maybe I'm juste misusing it, and we are always supposed to have a transparent content ?

Thank you very much for your help,
Paul.

@ricknout
Copy link
Owner

@paulnicolet unfortunately I don't think that's possible. However, if you're going to have a view that fills the whole bottom sheet with a color, why not rather use app:backgroundTint="@android:color/black" on the bottom sheet itself (i.e. FrameLayout in this case)?

@paulnicolet
Copy link

@ricknout, thanks for your reply ! In my case the bottom sheet is used as a container, and I do some fragment transactions to change its content when navigating, then I might need different background colors depending on the content fragment.
But that's ok, I will use the bottom sheet backgroundTint as a workaround 😉
Thanks again !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants