Faltenreich/SkeletonLayout

Issues supporting CardView

Aaub opened this issue · 1 comments

Aaub commented

Hello,

I create an issues because I noticed 2 things using the lib with CardView. First is my app crash as soon as I try to apply createSkeleton()onto a CardView. CardView actually extend ViewGroup so it means that it would be possible to apply such a method. I tried to put breakpoints everywhere but I was not able to find exactly what is happening. Here is the stackTrace :

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.jobteaser.jobteaser, PID: 30464
    java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to androidx.constraintlayout.widget.ConstraintLayout$LayoutParams
        at androidx.constraintlayout.widget.ConstraintLayout.getTargetWidget(ConstraintLayout.java:1144)
        at androidx.constraintlayout.widget.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:1028)
        at androidx.constraintlayout.widget.ConstraintLayout.updateHierarchy(ConstraintLayout.java:803)
        at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1561)
        at android.view.View.measure(View.java:24604)
        at androidx.core.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1562)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at androidx.core.widget.NestedScrollView.onMeasure(NestedScrollView.java:584)
        at android.view.View.measure(View.java:24604)
        at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onMeasure(SwipeRefreshLayout.java:641)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6885)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:24604)
        at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1414)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.widget.ScrollView.onMeasure(ScrollView.java:452)
        at android.view.View.measure(View.java:24604)
        at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
        at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6885)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6885)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6885)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6885)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6885)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at com.android.internal.policy.DecorView.onMeasure(DecorView.java:767)
        at android.view.View.measure(View.java:24604)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3089)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1911)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2203)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1799)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7772)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1058)
        at android.view.Choreographer.doCallbacks(Choreographer.java:865)
        at android.view.Choreographer.doFrame(Choreographer.java:800)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1043)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7520)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

The other thing I noticed is when I applySkeleton()onto a RecycleView with items based on a CardView, all the CardView style does not appear when the shimmer is playing. I loose the elevation and the cornerRadius which lead to flat my items.

I have not seen any issue going in that direction.

Thank you in advance for your help

Alex

it doesn't crash on my code but what i find out that this library doesn't support cardview .
this might help you #13