team-supercharge / ShimmerLayout

DEPRECATED - Memory efficient shimmering effect for Android applications by Supercharge.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does it work with LinearLayouts as children?

omatrot opened this issue · comments

I would say that it does not.
Should I convert my linearlayouts to relativelayouts ?

Hi @omatrot, yes it should. It is a normal FrameLayout which can have any kind of children views.
Could you provide a sample code where it is not works?

EDIT: I may be wrong but it seems to me that a background color is needed for the animation to be visible right ?


Of course, here we go:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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" android:orientation="vertical">
    <io.supercharge.shimmerlayout.ShimmerLayout android:id="@+id/shimmer_text" android:layout_width="wrap_content" android:layout_height="40dp" android:layout_gravity="center_horizontal" android:layout_marginTop="50dp" android:paddingLeft="30dp" android:paddingRight="30dp" app:shimmer_animation_duration="1200">
        <LinearLayout android:orientation="horizontal" android:weightSum="20" android:layout_width="match_parent" android:layout_height="wrap_content">
            <TextView android:layout_height="wrap_content" android:minLines="2" android:layout_width="0dp" android:layout_weight="16" android:id="@+id/qol1" android:text="Avoir du temps pour moi" />
            <TextView android:layout_height="wrap_content" android:layout_width="0dp" android:id="@+id/score_qol1" android:text="6" android:layout_weight="2" style="@android:style/TextAppearance.DeviceDefault.Large" android:gravity="right" />
            <TextView android:id="@+id/score_qol1_10" android:text="/10" android:gravity="left" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" />
        </LinearLayout>
    </io.supercharge.shimmerlayout.ShimmerLayout>
</LinearLayout>

The inner most horizontal Linear Layout is used to size TextViews children upon the individual weight.

So, the first thing is that you should start the animation either from Java/Kotin code or at the XML by adding the shimmer_auto_start attribute.

The text color here is very similar to the default shimmer color so you cannot see the animation itself. If you change the shimmer_color attribute for example to red, then you can see the animation.

As for you question, anything inside the ShimmerLayout which has a color will run the animation.

Is it working by applying the above instructions?

Ok understood, thanks for the clarification.