2012-06-21 20 views
6

Estoy trabajando en una aplicación, donde en mi página de inicio tengo que dar animación brillante y decolorante a un logotipo (imageview) intenté mucho y no pude encontrar cómo dar animación de efecto de resplandor y sé resplandor efecto para el evento onclick favor me ayude con este problema Gracias de antemanoefecto de brillo de animación de Android en imageview

public class CustomView extends ImageView{ 
public CustomView(Context context, AttributeSet attrs, int defStyle) { 
    super(context, attrs, defStyle); 
} 
public CustomView(Context context, AttributeSet attrs) { 
    super(context, attrs); 
} 
public CustomView(Context context) { 
    super(context); 
} 
boolean drawGlow = false; 
//this is the pixel coordinates of the screen 
float glowX = 0; 
float glowY = 0; 
//this is the radius of the circle we are drawing 
float radius = 20; 
//this is the paint object which specifies the color and alpha level 
//of the circle we draw 
Paint paint = new Paint(); 
{ 
    paint.setAntiAlias(true); 
    paint.setColor(Color.WHITE); 
    paint.setAlpha(50); 
}; 

@Override 
public void draw(Canvas canvas){ 
    super.draw(canvas); 
    if(drawGlow) 
     canvas.drawCircle(glowX, glowY, radius, paint); 
} 
@Override 
public boolean onTouchEvent(MotionEvent event){ 
    if(event.getAction() == MotionEvent.ACTION_DOWN){ 
     drawGlow = true; 
    }else if(event.getAction() == MotionEvent.ACTION_UP) 
     drawGlow = false; 

    glowX = event.getX(); 
    glowY = event.getY(); 
    this.invalidate(); 
    return true; 
} 
} 

este código es para eventos táctiles i quieren animación

+0

tipo de animación intermitente ¿verdad? necesita – Khan

+0

@come en http://chat.stackoverflow.com/rooms/11936/android-lite – Khan

+0

gracias @Khan encontré la respuesta –

Respuesta

2

su simple

hacer 2 series de imágenes uno es luz y otra uno será soleado (Brillante)

Luego puede usar una AlphaAnimation para animar la imagen.

+0

por favor dame un código de muestra Gracias por su tiempo –

18

Para la comprobación del efecto Resplandor Glow effect y para

Para el tipo de abrir y cerrar de animación utilizan este funciona tiene que cambiar Reapeatcount y duración accroding a su requerimiento

AlphaAnimation blinkanimation= new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible 
blinkanimation.setDuration(300); // duration - half a second 
blinkanimation.setInterpolator(new LinearInterpolator()); // do not alter animation rate 
blinkanimation.setRepeatCount(3); // Repeat animation infinitely 
blinkanimation.setRepeatMode(Animation.REVERSE); 

después de su uso se indican a continuación

imageview.startAnimation(blinkanimation); or imageview.setAnimation(blinkanimation); 
+0

quiero efecto brillante efecto no parpadeante por favor, ayúdenme –

+0

@ThiruVT he editado mi ans y lo compruebo – Khan

+0

es para el evento táctil en esa vista de cuadrícula quiero animación de cualquier manera, gracias –

Cuestiones relacionadas