Skip to content Skip to sidebar Skip to footer

Fading The Image Border In An Imageview

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.

Solution 1:

Override methods in ImageView as written below:

privatefloat FadeStrength = 1.0f;
privateint FadeLength = 40px;

@Override
protectedfloatgetTopFadingEdgeStrength() {
    return FadeStrength;
}

@Override
protectedfloatgetBottomFadingEdgeStrength() {
    return FadeStrength;
}

@Override
protectedfloatgetLeftFadingEdgeStrength() {
    return FadeStrength;
}

@Override
protectedfloatgetRightFadingEdgeStrength() {
    return FadeStrength;
}

And on initialization of view add lines:

setFadingEdgeLength(FadeLength);
setVerticalFadingEdgeEnabled(true);
setHorizontalFadingEdgeEnabled(true);

Solution 2:

Try this work around: Don't need to extend ImageView

imageView.scrollTo(1,0);
imageView.setHorizontalFadingEdgeEnabled(true);
imageView.setFadingEdgeLength(40);

Post a Comment for "Fading The Image Border In An Imageview"