boss直聘Android找工作界面,Android仿Boss直聘我的界面滑动效果
最近在找工作,我在使用boss投简历的时候,看到boss的我的界面蛮有意思的,就想如何去实现它,可能是职业病吧,所以就打算仿一下。先看下仿的效果。
image
其实我们拿到这个效果的时候,看到滑动,折叠等效果就应该想到了Material design,那么我们现在就可以基本的布局下。
activity_main.xml布局
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:layout_behavior="com.zwl.mybossdemo.AppBarLayoutOverScrollViewBehavior">
android:id="@+id/mCollapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
android:id="@+id/topview"
layout="@layout/layout_top_view"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.9" />
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:elevation="5dp"
android:gravity="center"
android:text="大白"
android:textColor="@android:color/white"
android:textSize="28sp"
android:textStyle="bold"
android:typeface="monospace" />
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0"
android:background="@color/colorAccent"
app:layout_collapseMode="pin" />
layout_top_view.xml
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:orientation="vertical"
android:paddingTop="40dp"
app:layout_collapseMode="parallax">
android:id="@+id/top_view_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/top_view">
android:id="@+id/jianli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_marginLeft="30dp"
android:paddingTop="35dp"
android:paddingBottom="15dp"
android:text="我的在线简历 "
android:textColor="@android:color/white" />
android:id="@+id/me_icon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:src="@drawable/boss_avatar_7" />
android:id="@+id/top_view"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp">
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="301\n沟通过"
android:textColor="@android:color/white"
android:textSize="16sp" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="301\n沟通过"
android:textColor="@android:color/white"
android:textSize="16sp" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="301\n沟通过"
android:textColor="@android:color/white"
android:textSize="16sp" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="301\n沟通过"
android:textColor="@android:color/white"
android:textSize="16sp" />
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal|bottom">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/boss_card_bg" />
layout_content.xml 这里就是一个图片 截取Boss的
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:clickable="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/boss_user_bottom" />
上面的activity_main.xml中可以看到 我自定义了一个AppBarLayout的behavior, AppBarLayoutOverScrollViewBehavior 其实所有的效果都是这这里去实现的。
AppBarLayoutOverScrollViewBehavior
public class AppBarLayoutOverScrollViewBehavior extends AppBarLayout.Behavior {
private int mAppBarHeight;
private View mCardView;
private boolean isAnimate;
private float mTotalDy;
private float mLastScale;
private int mLastBottom;
private int mCardViewHeight;
private int mLimitHeight;
private View mToolBar;
private float scaleValue = 2f / 3;// 显示卡片的三分之一 所以抛出三分之二
private View mNameTitle;
public AppBarLayoutOverScrollViewBehavior() {
}
public AppBarLayoutOverScrollViewBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onLayoutChild(CoordinatorLayout parent, AppBarLayout abl, int layoutDirection) {
boolean handled = super.onLayoutChild(parent, abl, layoutDirection);
if (null == mCardView) {
mCardView = parent.findViewById(R.id.cardview);
}
if (null == mToolBar) {
mToolBar = parent.findViewById(R.id.toolbar);
}
if (null == mNameTitle) {
mNameTitle = parent.findViewById(R.id.name);
}
init(abl);
return handled;
}
@Override
public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY) {
if (velocityY > 100) {
isAnimate = false;
}
return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
}
@Override
public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout abl, View target, int type) {
super.onStopNestedScroll(coordinatorLayout, abl, target, type);
//恢复位置
if (abl.getBottom() > mLimitHeight) {
recovery(abl);
}
}
@Override
public boolean onStartNestedScroll(CoordinatorLayout parent, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes, int type) {
//开始滚动了 就动画归位
isAnimate = true;
return super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type);
}
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
if (mCardView != null && ((dy <= 0 && child.getBottom() >= mLimitHeight) || (dy > 0 && child.getBottom() > mLimitHeight))) {
scrollY(child, target, dy);
} else {
setViewAlpha(child, dy);
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
}
}
/**
* 初始化数据
*
* @param appBarLayout
*/
private void init(final AppBarLayout appBarLayout) {
appBarLayout.setClipChildren(false);
//整个AppbarLayout高度
mAppBarHeight = appBarLayout.getMeasuredHeight();
//卡片的高度
mCardViewHeight = mCardView.getMeasuredHeight();
//折叠正常的高度
mLimitHeight = mAppBarHeight - (int) (mCardViewHeight * scaleValue);
//默认1s折叠
appBarLayout.postDelayed(new Runnable() {
@Override
public void run() {
ValueAnimator anim = ValueAnimator.ofFloat(0, 1f).setDuration(200);
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
appBarLayout.setBottom((int) (mAppBarHeight - value * mCardViewHeight * scaleValue));
}
});
anim.start();
}
}, 1000);
}
/**
* 混动
*
* @param child
* @param target
* @param dy
*/
private void scrollY(AppBarLayout child, View target, int dy) {
mTotalDy += -dy;
mTotalDy = Math.min(mTotalDy, mLimitHeight);
mLastScale = Math.max(1f, 1f + (mTotalDy / mLimitHeight));
mLastBottom = mLimitHeight + (int) (mCardViewHeight * scaleValue * (mLastScale - 1));
child.setBottom(mLastBottom);
target.setScrollY(0);
}
/**
* 根据滑动设置 toolbar 名字显示效果
*
* @param target
* @param dy
*/
private void setViewAlpha(View target, int dy) {
float percent = Math.abs(target.getY() / mLimitHeight);
if (percent >= 1) {
percent = 1f;
}
//设置toolbar的透明度
mToolBar.setAlpha(percent);
//设置名字缩放
mNameTitle.setScaleX(Math.max(0.8f, 1 - percent));
mNameTitle.setScaleY(Math.max(0.8f, 1 - percent));
//设置名字平移
int offset = mNameTitle.getTop() - mToolBar.getTop();
mNameTitle.setTranslationY(-offset * percent);
}
/**
* 恢复位置
*
* @param abl
*/
private void recovery(final AppBarLayout abl) {
if (mTotalDy >= 0) {
mTotalDy = 0;
if (isAnimate) {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f).setDuration(200);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
int offsetY = abl.getBottom() - mLimitHeight;
abl.setBottom((int) (abl.getBottom() - (value * offsetY)));
abl.setScrollY(0);
}
});
valueAnimator.start();
} else {
abl.setBottom(mLimitHeight);
abl.setScrollY(0);
}
}
}
}
其实代码很简单 ,所以就不在讲解了,主要就是通过监听滑动距离来设置控件的属性,这里附上github链接,可以直接下载看下。
boss直聘Android找工作界面,Android仿Boss直聘我的界面滑动效果相关推荐
- 写给即将/正在找工作的Android攻城狮
写给即将/正在找工作的Android攻城狮 版权声明:转载必须注明本文转自严振杰的博客:http://blog.yanzhenjie.com 这段时间从北上广深杭不断传来一两个月找不到工作的消息,我一 ...
- 《Android 开发入门》我为什么要在Android找工作越来越难的时候开始学习它
近期一方面是所在的公司招聘Java开发人员很难招到合适的,投简历的人很少:而另一方面,经常听身边的人说Android.iOS方面找工作不好找,特别是没什么经验的,经验比较少的!说是不好找,但在我家所在 ...
- 我为什么要在Android找工作越来越难的时候开始学习它
近期一方面是所在的公司招聘Java开发人员很难招到合适的,投简历的人很少:而另一方面,经常听身边的人说Android.iOS方面找工作不好找,特别是没什么经验的,经验比较少的!说是不好找,但在我家所在 ...
- Android找工作好像越来越难了
你发现了嘛? 这两年学Android找工作的朋友,普遍比以前难了很多. 以前,尤其是十年前左右,你会写几个Demo,就根本不用愁找工作的事. 现在,你除了要熟练应用各大组件之外,至少也要会懂点Fram ...
- boss直聘Android找工作界面,仿Boss直聘我的界面滑动效果
好久没有写博客了,最近在找工作,我在使用boss投简历的时候,看到boss的我的界面蛮有意思的,就想如何去实现它,可能是职业病吧,所以就打算仿一下.先看下仿的效果. 其实我们拿到这个效果的时候,看到滑 ...
- android简历!写给即将正在找工作的Android攻城狮,已拿offer
前言 想要成為一名優秀的Android開發,你需要一份完備的 知識體系,在這裏,讓我們一起成長為自己所想的那樣. 金九银十是大家的換工作潮,在這波浪潮裡沉浮的我經歷過快一個月的面試後,決定把這些遇到的 ...
- android lint工作机制,Android架构
MVC mvc model view controller 模式视图控制器 M: 业务逻辑处理 V:处理数据显示的部分 C:Activity处理用户交互的问题,中间桥梁的作用,解耦的作用. 特点: 耦 ...
- android 微信缩小通话界面_Android仿微信多人音视频通话界面
工作中需要实现一个类似微信多人视频通话功能的界面,分别使用自定义viewgroup和自定义layoutmanager的方式进行了实现.最终工作中采用了layoutmanager,因为可以使用paylo ...
- android抖音评论列表,BottomSheetBehavior+CoordinatorLayout实现抖音评论列表滑动效果
效果图 bottomsheet.gif 最近项目有这个需求, 自己能想出的最简单直接的实现办法, 稍稍改动也能支持ListView的情况. 效果说明 支持列表滑动 只有当列表滑动到顶端时, 继续下滑, ...
最新文章
- 基于oracle的数据系统,基于Oracle 的数据库系统
- 利用https访问站点(基于linux系统)
- redis通过pipeline提升吞吐量
- excel亮灯怎么设置_Excel表格技巧—怎么给表格设置密码
- 【HihoCoder - 1880】地铁环线 (前缀和,水题,模拟)
- 新监管形势下的数据流通合规技术解最新探究 (连载一)
- SSH中 三大框架的各自的作用及好处
- excel制图小技巧
- 计算机电脑配置ppt,计算机应用基础之word2010课件.ppt
- 用银行卡号查相应的归属银行,卡种类
- qconshanghai2015
- VSLAM学习记录-求导:李群与李代数
- MySQL 中 delete where in 语句的子查询限制
- 阿里面试官内部题库,阿里发布2022年Java岗(正式版)面试题
- python用*号输出字母c的图案_第1.6题:使用Python生成字母验证码图片
- GNU C++ 智能指针3-- 解析_Sp_counted_base类
- 【网络编程实践--陈硕】2.4.4 procmon 程序的设计实现
- 2017 计算机 暑期学校,科学网-2018,17年数学统计学计量经济暑期学校汇总-张慧铭的博文...
- Android开发——贝塞尔曲线解析
- 牛客网数据库SQL实战60—— 统计salary的累计和running_total
热门文章
- 近看图灵碗 (8. 我就是上帝) (上)
- Requirejs加载超时问题的一个解决方法:设置waitSeconds=0
- python3运行报错:TypeError: Object of type ‘type‘ is not JSON serializable解决方法(详细)
- 【vue】使用localStorage解决vuex在页面刷新后数据被清除的问题
- Freescale 车身控制模块(BCM) 解决方案
- 如果需要,npm检查并更新包
- 媒体查询中“屏幕”和“仅屏幕”之间有什么区别?
- 您能否提供一些示例,说明为什么用正则表达式很难解析XML和HTML? [关闭]
- 回滚到公共回购中的旧Git提交
- 《Apache Flink官方文档》 Apache Flink介绍