Android com.daimajia.slider.library.SliderLayout 去掉底部半透明标题背景
程序员文章站
2022-04-09 18:00:48
com.daimajia.slider.library.SliderLayout 是挺好用的轮播图控件,但是底部灰色背景有时候用不到,所以得去掉。 sliderLayout.setCustomAnimation(new DescriptionAnimation()); 这个方法是设置灰色背景动画 我 ......
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());