啊啊啊,我又来更新了。

哈哈哈,分享最近有趣小点。

最近在做详情页滑动渐变显示与淡入淡出效果,我也是费尽脑筋查了又查,搜了又搜。

最后还是用最原生的方式实现了,多了不说少了不唠,仔细阅读以下文字。

note:接下来这个方法是获取view的原始有颜色,通过RGB计算将色值一点点调透明度。

private void setDetailTitleColor(int scrollY) {    if (mDetailTitle == null) {      return;    }    if (scrollY == 0) {      mDetailTitle.setTextColor(Colo.White);    } else {      int color = mDetailTitle.getTextColors().getDefaultColor();      int r = Color.red(color);      int g = Color.green(color);      int b = Color.blue(color);      int changeToColor = Color.argb((255 * (scrollY - 1)), r, g, b);      mDetailTitle.setTextColor(changeToColor);    } }

附赠:渐渐隐藏和渐渐显示的动画

  public static void fadeInVisible(@NonNull View view, float startAlpha, float endAlpha) {    if (view.getVisibility() == View.VISIBLE) {      return;    }    view.setVisibility(View.VISIBLE);    Animation animation = new AlphaAnimation(startAlpha, endAlpha);    animation.setDuration(500);    view.startAnimation(animation);  }
  public static void fadeOutGone(@NonNull View view, float startAlpha, float endAlpha) {    if (view.getVisibility() == View.GONE) {      return;    }    view.setVisibility(View.GONE);    Animation animation = new AlphaAnimation(startAlpha, endAlpha);    animation.setDuration(500);    view.startAnimation(animation);  }

调用方式:

  //渐渐显示  fadeInVisible(mDetailTitle, 0f, 1f);  //渐渐隐藏  fadeOutGone(mDetailTitle, 1f, 0f);

 

 

更多相关文章

  1. Android通过原生方式获取经纬度与城市信息的方法
  2. Android Studio 基础 之 一键快速实现一个类的 构造函数、getter
  3. Android中的UID和PID意义,及查看方式
  4. Android绘图机制(三)——自定义View的实现方式以及半弧圆新控件
  5. 【Android 性能优化】应用启动优化 ( 安卓应用启动分析 | Launch
  6. android xml中 颜色透明度(不透明度)参照表

随机推荐

  1. Centos7 安装部署 Python-3.6.1
  2. 在Linux中使用PAM进行身份验证为什么它可
  3. 删除目录软链接注意事项
  4. linux网卡实现高可用:team链路聚合
  5. Linux网络设备驱动架構學習(三)
  6. 一·创建Linux服务器(基于阿里云)
  7. Linux中动态链接库总结
  8. Linux工程实践学习笔记——基于主机系统
  9. linux 内核模块学习
  10. Linux内核中的container_of函数简要介绍