How to change createCircularReveal() color? - android

Like the title said, I'm looking a easy way to customize the color used in reveal.
I want to use official code if it's possible (avoiding 3rd party libraries).
I'm using the usual code:
Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
myView.setVisibility(View.VISIBLE);
anim.start();

The circular reveal animation doesn't have any color. If you want color, you need to set the background color on the view you are providing to circular reveal.

Related

Android ValueAnimator interpolating crazy colors

I'm trying to use a very simple code to fade the background color change in a textview
the idea is to chose a new color, than have it fade from transparent to the desired color, here is the code:
ValueAnimator anim = new ValueAnimator();
anim.setEvaluator(ArgbEvaluator.getInstance());
anim.setDuration(1500);
anim.setIntValues(hightlightColor & 0x00FFFFFF, hightlightColor);
// txtView.setBackgroundColor(hightlightColor);
anim.addUpdateListener(animation -> txtView.setBackgroundColor((int) animation.getAnimatedValue()));
anim.start();
highlight color is just a green i'm using for example, txtview is a valid textview and the current background is null
but instead of creating a fade in shades of green the code results in a crazy rainbow like interpolation, that ends exactly in the desired green, but all intermediate values are shit
I thought it might be the alpha channel so i tested starting from white to green but the intermediate colors were all crazy also
MY APP MINSDK IS 16 SO I CANT USE ValueAnimator.ofArgb()
here is how it looks

Chat bubble animation

I want to achieve animation when I send my message it goes from bottom to top like flying a bird (though I have done it :P) but while flying, that chat bubble view's radius is also changing(This is the thing I am not able to achieve).
Please help me to achieve this kind of animation or give me some sort of hint.
Thank you
I have used below code to set radius and then translate that view using xml file but not able to change radius on the go.
GradientDrawable gd = new GradientDrawable();
// Specify the shape of drawable
gd.setShape(GradientDrawable.RECTANGLE);
// Set the fill color of drawable
gd.setColor(Color.TRANSPARENT); // make the background transparent
// Create a 2 pixels width red colored border for drawable
gd.setStroke(2, Color.RED); // border width and color
// Make the border rounded
gd.setCornerRadius(15.0f);
((RelativeLayout) findViewById(R.id.rlvView)).setBackground(gd);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.item_animation_from_bottom);
((RelativeLayout) findViewById(R.id.rlvView)).startAnimation(animation);
You need to use ObjectAnimator (derivative class of ValueAnimator) to achieve animate any value (visible/invisible) of a view. Code below animate cornerRadius for one time from 15.0f to 0. Please try, I hope it helps.
// Make the border rounded
gd.setCornerRadius(15.0f);
((RelativeLayout) findViewById(R.id.rlvView)).setBackground(gd);
ObjectAnimator animator = ObjectAnimator.ofFloat(gd, "cornerRadius", 0);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(800);
animator.start();

Animation engine does not animate a view

I have the following animation
ValueAnimator colorAnim = ObjectAnimator.ofInt(contentBg, "backgroundColor", /*transparent*/0x0, /*dark*/0xcc000000);
colorAnim.setDuration(3000);
colorAnim.setEvaluator(new ArgbEvaluator());
colorAnim.start();
so what I want is to animate a contentBg from transparent to almost opaque dark. However, what I gets is just a transparent view, and after 3 seconds it gets instantly dark (end value of animation).
What should I do to make it work properly?
I am using nineoldandroids lib.
Have you tried to animate alpha only?
ValueAnimator colorAnim = ObjectAnimator.ofFloat(contentBg, View.ALPHA, 0, 0.8);
colorAnim.setDuration(3000);
colorAnim.start();
EDIT: from here it seems there is a problem with ArgbEvaluator evaluating alpha values. You can try the patched version provided in https://github.com/EaseTheWorld/PaintAnimator/blob/master/src/dev/easetheworld/animator/ArgbEvaluator2.java
Actually solved it myself by narrowing down my question to animating just alpha.
How to set View alpha in lower Api than 11?

Changing opacity of a texture on the fly in opengl?

I am new to opengl and have no idea how to deal with opacity. I have two layers that are overlapped i am drawing both the layers on to the screen. I want to fade out the one in the foreground to transtition to the background image. Is there any way to do this?? Here's my draw method.
public void draw(GL10 gl10) {
gl10.glDisable(GL10.GL_BLEND);
gl10.glEnable(GL10.GL_BLEND);
gl10.glBlendFunc(GL10.GL_TRUE, GL10.GL_ONE_MINUS_SRC_ALPHA);
gl10.glClearColor(0F, 0F, 0F, 0);
gl10.glBindTexture(GL10.GL_TEXTURE_2D, this.mTextureId);
this.layer1.draw(gl10); // i want to transition from this layer
this.layer2.draw(gl10); // to this layer by changing opacity
}
I dont know even i framed my question correctly. Hope you get it :)
Well it depends on the method you're using for this transition. I have a similar situation with an animation view. About your opacity problem, can't you use
View v;
int i = 0; /*Values from 0 to 1, float cast might be needed for intermediate values*/
v.setAlpha(i);
this.layer2.setAlpha(i);
Or something like that, isn't this applicable in your case?

How do I set an Android View's transparency with animation?

I need to set the initial transparency for a TextView, but I don't know how to do it. On iPhone/iOS, it can be done easily with the alpha property. On Android, I've tried to set the alpha using AlphaAnimation but it's no good -- it doesn't work. It just returns to 100% alpha when the animation ends.
AlphaAnimation anim = new AlphaAnimation(1, 0.2f);
anim.setDuration(5000);
textView.startAnimation(anim);
Any ideas guys?
You can set the alpha channel directly in a color value that you assign to the TextView. See Available Resource Types.

Categories

Resources