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

Relative width, height and a few other attributes cannot be set because they need floats but setters are typed as Ints #31

Closed aphexcx closed 6 years ago

aphexcx commented 7 years ago

I can't set the relative width:

        app:relative_width="0.3"
java.lang.UnsupportedOperationException: Can't convert value at index 9 to dimension: type=0x4
   at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:720)
  at com.facebook.shimmer.ShimmerFrameLayout.<init>(ShimmerFrameLayout.java:226)
   at com.facebook.shimmer.ShimmerFrameLayout.<init>(ShimmerFrameLayout.java:147)
                                                                                        ... 33 more

Looking at the source, this is because the setter inexplicably takes an int and casts it to float, instead of taking a float in the first place.

 public void setRelativeWidth(int relativeWidth) {
    this.mMask.relativeWidth = (float)relativeWidth;
    this.resetAll();
  }

This should be an easy fix. I'd open a PR myself if I didn't have a deadline to meet.