8

私はアプリケーションに取り組んでいます。私のホームページでは、ロゴ (イメージビュー) にグロー効果とフェード効果のアニメーションを与える必要があります。多くのことを試しましたが、グロー効果のアニメーションを与える方法が見つかりませんでした。この問題で私を助けてください よろしくお願いします

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;
}
}

このコードは、アニメーションが必要なタッチイベント用です

4

2 に答える 2

20

グロー効果チェックグロー効果

まばたきタイプのアニメーションの場合、これは機能します。必要に応じて Repeatcount と Duration を変更する必要があります。

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);

以下のように使用した後

imageview.startAnimation(blinkanimation);  or imageview.setAnimation(blinkanimation);
于 2012-06-21T05:02:57.087 に答える
3

それは簡単です

明るい画像と晴れた画像を2セット作る(Bright)

次に、AlphaAnimation を使用して画像をアニメーション化できます。

于 2012-06-21T04:47:50.460 に答える