当前位置: 萬仟网 > IT编程>移动>Android > Android com.daimajia.slider.library.SliderLayout 去掉底部半透明标题背景

Android com.daimajia.slider.library.SliderLayout 去掉底部半透明标题背景

2019年01月13日 09:27  | 萬仟网IT编程  | 我要评论

com.daimajia.slider.library.sliderlayout 是挺好用的轮播图控件,但是底部灰色背景有时候用不到,所以得去掉。

 

 

sliderlayout.setcustomanimation(new descriptionanimation()); 这个方法是设置灰色背景动画

我们重新写一个类descriptionanimation1,内容同descriptionanimation,

import android.view.view;

import com.daimajia.slider.library.animations.baseanimationinterface;
import com.daimajia.slider.library.r;
import com.nineoldandroids.animation.objectanimator;
import com.nineoldandroids.animation.valueanimator;
import com.nineoldandroids.view.viewhelper;

/**
 * a demo class to show how to use {@link com.daimajia.slider.library.animations.baseanimationinterface}
 * to make  your custom animation in {@link com.daimajia.slider.library.tricks.viewpagerex.pagetransformer} action.
 */
public class descriptionanimation1 implements baseanimationinterface {

    @override
    public void onpreparecurrentitemleavescreen(view current) {
        view descriptionlayout = current.findviewbyid(r.id.description_layout);
        if(descriptionlayout!=null){
            current.findviewbyid(r.id.description_layout).setvisibility(view.invisible);
        }
    }

    /**
     * when next item is coming to show, let's hide the description layout.
     * @param next
     */
    @override
    public void onpreparenextitemshowinscreen(view next) {
        view descriptionlayout = next.findviewbyid(r.id.description_layout);
        if(descriptionlayout!=null){
            next.findviewbyid(r.id.description_layout).setvisibility(view.invisible);
        }
    }


    @override
    public void oncurrentitemdisappear(view view) {

    }

    /**
     * when next item show in viewpagerex, let's make an animation to show the
     * description layout.
     * @param view
     */
    @override
    public void onnextitemappear(view view) {

        view descriptionlayout = view.findviewbyid(r.id.description_layout);
        if(descriptionlayout!=null){
            float layouty = viewhelper.gety(descriptionlayout);
            view.findviewbyid(r.id.description_layout).setvisibility(view.gone);
            valueanimator animator = objectanimator.offloat(
                    descriptionlayout,"y",layouty + descriptionlayout.getheight(),
                    layouty).setduration(500);
            animator.start();
        }

    }
}

红色代码,把背景隐藏掉就行了,然后 sliderlayout.setcustomanimation(new descriptionanimation1());

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

◎已有 0 人评论

Copyright © 2019  萬仟网 保留所有权利. 粤ICP备17035492号-1
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com