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.32k stars 697 forks source link

[Question] How to have shimmer effect to the container #82

Closed nksaroj closed 5 years ago

nksaroj commented 5 years ago

I would like to have the simmer effect to the container until the text arrives from the backend But I've noticed the simmer effect animation is taking effect only to text after it arrives from the backend. However the animation never shows earlier.

            <com.facebook.shimmer.ShimmerFrameLayout
                android:id="@+id/cmsShimmerContainer"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="40dp"
                android:layout_marginTop="10dp"
                android:layout_marginRight="40dp"
                app:shimmer_clip_to_children="true"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                android:layout_marginBottom="50dp"
                app:layout_constraintTop_toBottomOf="@+id/textViewPageHeader"
                app:layout_constraintVertical_bias="0.0">

                <TextView
                    android:id="@+id/markdownViewContentSummary"
                    style="@style/Secondary.TextView.HelveticaNeueLight.Light"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"'
                  android:minHeight="500dp"
                    android:lineSpacingExtra="4sp"
                    android:scrollbars="none" />
            </com.facebook.shimmer.ShimmerFrameLayout>

 cmsShimmerContainer.startShimmer()
xiphirx commented 5 years ago

ShimmerFrameLayout only applies the effect to its children, not itself. You will need to provide a dummy child view that will have the shimmer effect applied to it while your text is loading.