经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » Android » 查看文章
Android com.daimajia.slider.library.SliderLayout 去掉底部半透明标题背景
来源:cnblogs  作者:骑猪兜风的小菜鸡  时间:2019/1/14 9:35:02  对本文有异议

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

 

 

sliderLayout.setCustomAnimation(new DescriptionAnimation()); 这个方法是设置灰色背景动画

我们重新写一个类DescriptionAnimation1,内容同DescriptionAnimation,

  1. import android.view.View;
  2. import com.daimajia.slider.library.Animations.BaseAnimationInterface;
  3. import com.daimajia.slider.library.R;
  4. import com.nineoldandroids.animation.ObjectAnimator;
  5. import com.nineoldandroids.animation.ValueAnimator;
  6. import com.nineoldandroids.view.ViewHelper;
  7. /**
  8. * A demo class to show how to use {@link com.daimajia.slider.library.Animations.BaseAnimationInterface}
  9. * to make your custom animation in {@link com.daimajia.slider.library.Tricks.ViewPagerEx.PageTransformer} action.
  10. */
  11. public class DescriptionAnimation1 implements BaseAnimationInterface {
  12. @Override
  13. public void onPrepareCurrentItemLeaveScreen(View current) {
  14. View descriptionLayout = current.findViewById(R.id.description_layout);
  15. if(descriptionLayout!=null){
  16. current.findViewById(R.id.description_layout).setVisibility(View.INVISIBLE);
  17. }
  18. }
  19. /**
  20. * When next item is coming to show, let's hide the description layout.
  21. * @param next
  22. */
  23. @Override
  24. public void onPrepareNextItemShowInScreen(View next) {
  25. View descriptionLayout = next.findViewById(R.id.description_layout);
  26. if(descriptionLayout!=null){
  27. next.findViewById(R.id.description_layout).setVisibility(View.INVISIBLE);
  28. }
  29. }
  30. @Override
  31. public void onCurrentItemDisappear(View view) {
  32. }
  33. /**
  34. * When next item show in ViewPagerEx, let's make an animation to show the
  35. * description layout.
  36. * @param view
  37. */
  38. @Override
  39. public void onNextItemAppear(View view) {
  40. View descriptionLayout = view.findViewById(R.id.description_layout);
  41. if(descriptionLayout!=null){
  42. float layoutY = ViewHelper.getY(descriptionLayout);
  43. view.findViewById(R.id.description_layout).setVisibility(View.GONE);
  44. ValueAnimator animator = ObjectAnimator.ofFloat(
  45. descriptionLayout,"y",layoutY + descriptionLayout.getHeight(),
  46. layoutY).setDuration(500);
  47. animator.start();
  48. }
  49. }
  50. }

红色代码,把背景隐藏掉就行了,然后 sliderLayout.setCustomAnimation(new DescriptionAnimation1());

 

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号