Reputation: 4698
How to fill a image view background such that its transparent area will be filled by some color.
I want to fill below image -
and filled image will be like -
i want to fill black area of image only with animation from bottom to top.
Please suggest some animation by which i can do desire animation.
Thanks in advance
Upvotes: 0
Views: 889
Reputation: 821
U can try adding it in code
ImageView backgroundImg = (ImageView) findViewById(R.id.backgroundImg);
backgroundImg.setBackgroundColor(Color.rgb(100, 100, 50));
This will also solve your problem. Just add this in your ImageView tag.
android:background="@android:color/red"
Check this Im not sure. But check this snippet
You can simply use ArgbEvaluator which is available since API 11 (Honeycomb):
ValueAnimator anim = new ValueAnimator();
anim.setIntValues(color1, color2);
//anim..setIntValues(Color.parseColor("#FFFFFF"), Color.parseColor("#000000"));
anim.setEvaluator(new ArgbEvaluator());
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
backgroundImg.setBackgroundColor((Integer)valueAnimator.getAnimatedValue());
}
});
anim.setDuration(300);
anim.start();
Even better, beginning with API 21 (Lollipop 5.0) you can replace the first 3 lines in the code above with one:
ValueAnimator anim = ValueAnimator.ofArgb(color1, color2)
Upvotes: 1