首页 > 移动平台 > 详细

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

时间:2019-01-12 17:24:38      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:implement   代码   标题   ble   eol   appear   next   半透明   when   

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

 

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

标签:implement   代码   标题   ble   eol   appear   next   半透明   when   

原文:https://www.cnblogs.com/qzdf/p/10260121.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 designnerd.net 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号