facebookarchive / shimmer-android

An easy, flexible way to add a shimmering effect to any view in an Android app.
http://facebook.github.io/shimmer-android/
Other
5.31k stars 698 forks source link

Shimmer overlapping #95

Closed romankulykov closed 4 years ago

romankulykov commented 4 years ago

Screenshot_20200507-070928_ Here is my xml code of shimmer item in recycler view

<?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:padding="@dimen/activity_padding">

    <View
        android:id="@+id/thumbnail"
        android:layout_width="171dp"
        android:layout_height="35dp"
        android:layout_marginStart="28dp"
        android:layout_marginTop="28dp"
        android:layout_marginEnd="@dimen/activity_padding"
        android:layout_marginRight="@dimen/activity_padding"
        android:background="@color/placeholder_bg" />

    <View
        android:id="@+id/notifications"
        android:layout_width="33dp"
        android:layout_height="19dp"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="21dp"
        android:layout_marginEnd="44dp"
        android:layout_marginBottom="10dp"
        android:background="@color/placeholder_bg" />

    <View
        android:id="@+id/notificationText"
        android:layout_width="100dp"
        android:layout_height="10dp"
        android:layout_below="@id/notifications"
        android:layout_alignParentEnd="true"
        android:layout_toStartOf="@id/notifications"
        android:background="@color/placeholder_bg" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/thumbnail"
        android:layout_marginStart="28dp"
        android:layout_marginTop="24dp"
        android:layout_marginBottom="40dp"
        android:orientation="vertical">

        <View
            android:layout_width="96dp"
            android:layout_height="22dp"
            android:background="@color/placeholder_bg" />

        <View
            android:layout_width="87dp"
            android:layout_height="17dp"
            android:layout_marginTop="32dp"
            android:background="@color/placeholder_bg" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content">

                <View
                    android:layout_width="124dp"
                    android:layout_height="14dp"
                    android:layout_marginTop="11dp"
                    android:background="@color/placeholder_bg" />

                <View
                    android:layout_width="39dp"
                    android:layout_height="14dp"
                    android:layout_marginStart="5dp"
                    android:layout_marginTop="11dp"
                    android:background="@color/placeholder_bg" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content">

                <View
                    android:layout_width="39dp"
                    android:layout_height="14dp"
                    android:layout_marginTop="11dp"
                    android:background="@color/placeholder_bg" />

                <View
                    android:layout_width="124dp"
                    android:layout_height="14dp"
                    android:layout_marginStart="5dp"
                    android:layout_marginTop="11dp"
                    android:background="@color/placeholder_bg" />

            </LinearLayout>
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>
<com.facebook.shimmer.ShimmerFrameLayout
        android:id="@+id/flShimmer"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:orientation="vertical"
        app:duration="800"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
        tools:ignore="MissingConstraints">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/shimmerRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:orientation="vertical"
            android:paddingStart="8dp"
            android:paddingTop="8dp"
            android:paddingEnd="3dp"
            android:paddingBottom="8dp"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            tools:listitem="@layout/list_item_shop_shimmer_2" />

        <!--<LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <include layout="@layout/list_item_shop_shimmer_2" />

            <include layout="@layout/list_item_shop_shimmer_2" />

        </LinearLayout>-->

    </com.facebook.shimmer.ShimmerFrameLayout>

How i called in code: flShimmer.startShimmerAnimation() So what I do wrong ? Because xml that i used from example works fine

romankulykov commented 4 years ago

solved: just placed com.facebook.shimmer.ShimmerFrameLayout as item in recycler view and start animation in adapter