Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

ShimmerDrawable not working with View.LAYER_TYPE_HARDWARE #132

Open
fsgjlp opened this issue Jul 19, 2022 · 1 comment
Open

ShimmerDrawable not working with View.LAYER_TYPE_HARDWARE #132

fsgjlp opened this issue Jul 19, 2022 · 1 comment

Comments

@fsgjlp
Copy link

fsgjlp commented Jul 19, 2022

ShimmerDrawable not working with View.LAYER_TYPE_HARDWARE and View.LAYER_TYPE_SOFTWARE.

Environment: Android emulator, Pixel 4 api 31

    Shimmer shimmer = new Shimmer.ColorHighlightBuilder()
        .setBaseAlpha(0.7f)
        .setHighlightAlpha(0.9f)
        .setDuration(10000)
        .setDirection(Shimmer.Direction.TOP_TO_BOTTOM)
        .setAutoStart(true)
        .build();

    ShimmerDrawable shimmerDrawable = new ShimmerDrawable();
    shimmerDrawable.setShimmer(shimmer);

    ShimmerDrawable shimmerDrawable2 = new ShimmerDrawable();
    shimmerDrawable2.setShimmer(shimmer);

    ShimmerDrawable shimmerDrawable3 = new ShimmerDrawable();
    shimmerDrawable3.setShimmer(shimmer);

    appCompatImageView.setLayerType(View.LAYER_TYPE_NONE, null);
    appCompatImageView.setImageDrawable(shimmerDrawable);

    appCompatImageView2.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    appCompatImageView2.setImageDrawable(shimmerDrawable2);

    appCompatImageView3.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    appCompatImageView3.setImageDrawable(shimmerDrawable3);
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="LAYER_TYPE_NONE" />

  <androidx.appcompat.widget.AppCompatImageView
    android:id="@+id/appCompatImageView"
    android:layout_width="100dp"
    android:layout_height="100dp" />

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="LAYER_TYPE_HARDWARE" />

  <androidx.appcompat.widget.AppCompatImageView
    android:id="@+id/appCompatImageView2"
    android:layout_width="100dp"
    android:layout_height="100dp" />

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="LAYER_TYPE_SOFTWARE" />

  <androidx.appcompat.widget.AppCompatImageView
    android:id="@+id/appCompatImageView3"
    android:layout_width="100dp"
    android:layout_height="100dp" />
    
</LinearLayout>

Screenshot

@fsgjlp
Copy link
Author

fsgjlp commented Nov 17, 2022

@xiphirx, I would appreciate it if you could tell me why the problem is occurring.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant