I need to add a fading effect on a ImageView
.
In my situation I have a RelativeLayout
, the relative background in yellow and in the center of that background there is a ImageView
. Now I need to apply a fade affect on the edge of the ImageView
. Is this possible? (Android api 11+
)
I tried:
android:requiresFadingEdge="horizontal"
android:fadingEdge="horizontal"
android:fadingEdge="vertical"
android:fadingEdgeLength="40px"
but doesn't work..
This is an example of what I want. Like you can see the top and the left are fading, the right and bottom edge, instead, are not fading..
Thanks a lot!
Override methods in ImageView as written below:
private float FadeStrength = 1.0f;
private int FadeLength = 40px;
@Override
protected float getTopFadingEdgeStrength() {
return FadeStrength;
}
@Override
protected float getBottomFadingEdgeStrength() {
return FadeStrength;
}
@Override
protected float getLeftFadingEdgeStrength() {
return FadeStrength;
}
@Override
protected float getRightFadingEdgeStrength() {
return FadeStrength;
}
And on initialization of view add lines:
setFadingEdgeLength(FadeLength);
setVerticalFadingEdgeEnabled(true);
setHorizontalFadingEdgeEnabled(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With