Android,在ontouchListener中动态设置alpha

时间:2013-09-16 16:02:24

标签: android

我的touchlistener中的alpha动画有问题,我尝试这样做:

AlphaAnimation alpha;

public void animazione_touch(FrameLayout frame, android.view.MotionEvent event, int num_id_frame){
    if(event.getAction() == android.view.MotionEvent.ACTION_MOVE){
        x= (int) event.getRawX();
if (tmp==0){
    offset = x;
    tmp = 1;
}

if(offset < (x - width /5) || offset > (x + width /5) || start ==1)
{
    if(id_frame ==num_id_frame){
    params = new RelativeLayout.LayoutParams((int) (width ), (int) (height));
    params.leftMargin = x;
    params.topMargin = (int) (0);
    frame.setLayoutParams(params);
    avviato = 1;
    float ALPHA_FLOAT = Math.abs((x / width)-1);
    alpha = new AlphaAnimation(1f, ALPHA_FLOAT); 
    alpha.setDuration(0);
    alpha.setFillAfter(true); 
    scomparsa.startAnimation(alpha);
    }
}
        }//fine get action

我会在我的三星s4上创建像g + app这样的效果,当我从右向左拖动时,布局在下面,根据手指的位置设置alpha图像。

但没有出现!

0 个答案:

没有答案