Erlo

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

时间:2019-01-12 17:01   阅读:68次   来源:博客园页面报错

点赞 打赏

×打赏

支付宝

微信

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;

#zs#*
 * 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.
 #fzs#
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);
        }
    }

    #zs#*
     * When next item is coming to show, let's hide the description layout.
     * @param next
     #fzs#
    @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) {

    }

    #zs#*
     * When next item show in ViewPagerEx, let's make an animation to show the
     * description layout.
     * @param view
     #fzs#
    @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());

 

下一篇:Java多线程入门知识点梳理

评论留言

还没有评论留言,赶紧来抢楼吧~~

Erlo大厅()

* 这里是“吐槽厅”,所有人可看,只保留当天信息。

  • Erlo.vip2019-05-24 14:46:52Hello、欢迎使用吐槽厅,这里是个吐槽的地方。
  • 首页 笔记分享 案例展示 ERLO 搜索
    鼠标试试
    返回顶部