CRED-CLUB / synth-android

Synth is CRED's inbuilt library for using Neumorphic components in your app.
https://blog.cred.club/team-cred/design/world-meet-neumorphism-open-sourcing-our-ui-framework/
Apache License 2.0
1.01k stars 106 forks source link

ElevatedDrawable not working even after setting clipChildren = false #11

Open UvrajSB opened 3 years ago

UvrajSB commented 3 years ago

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipChildren="false" android:id="@+id/kindle_parentRL" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="#1C1D1E" android:clipToPadding="false">

<androidx.cardview.widget.CardView
    android:clipToPadding="false"
    android:layout_margin="20dp"
    android:id="@+id/kindle_parent_card_detail"
    android:background="@drawable/kindle_card"
    app:cardBackgroundColor="@color/cool_gray"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.Neumorph.Dark"
    style="@style/Widget.Neumorph.CardView"
    android:clipChildren="false">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_margin="30dp"
            android:elevation="50dp"
            android:clipChildren="false">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:layout_marginHorizontal="20dp"
            android:fontFamily="@font/poppins"
            android:textColor="@color/white"
            android:id="@+id/highlight_text"/>
        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="20dp"
            app:cardCornerRadius="10dp"
            android:paddingHorizontal="10dp"
            android:layout_centerHorizontal="true"
            app:cardBackgroundColor="@color/black"
            android:layout_below="@id/highlight_text"
            android:clipChildren="false">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="20dp"
                android:id="@+id/name_of_kindle"
                android:textSize="12sp"
                android:textColor="@color/lime"
                android:text="A General Introduction to Psychoanalysis"/>
        </androidx.cardview.widget.CardView>
        </LinearLayout>
</androidx.cardview.widget.CardView>

UvrajSB commented 3 years ago

holder.parent_card.background = ElevatedDrawable(NeuPlatformAppearance(SynthUtils.defaultBaseColor),40f,20f)

UvrajSB commented 3 years ago

I am facing this issue multiple times, even after setting clipChildren = false in parent view The bakground do come with a shade but it appears clipped

rishabhsinghbisht commented 2 years ago

Most likely your shadows are getting outside your parent’s bounds. So you’ll have to add clipChildren = false to the next immediate parent too.