php仿携程网站,三分钟带你仿携程飞机票首页炫酷交互

当前位置:我的异常网» Web前端 » 三分钟带你仿携程飞机票首页炫酷交互

三分钟带你仿携程飞机票首页炫酷交互

www.myexceptions.net  网友分享于:2013-12-23  浏览:0次

三分钟带你仿携程机票首页炫酷交互

这些效果熟悉MD的同学肯定一下就能够想到三大利器:CoordinatorLayout,AppBarLayout,CollapsingToolbarLayout。往这个方面想就对了,今天我们就要用这三个东西来搞一个炫酷的交互效果。先简单看一下这三大利器。

CoordinatorLayout

Design包下的控件,作用如其名字是用来协调操作控件的布局,可以通过自定义Behavior来协调和控制子View之间的交互。

AppBarLayout

继承自LinearLayout,在竖直方向的LinearLayout基础上增加了一些Material Design的设计概念,同样可以定义滑动时子View的交互方式。

CollapsingToolbarLayout

为Toolbar而生的控件,用来操控Toolbar实现一些炫酷的折叠效果,可以为Toolbar和StatusBar在滑动阀值时添加scrim效果以及控制Toolbar等其他子View滑动的视差滚动(parallax)

老规矩,先上布局文件:

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/coordinatorLayout"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/app_bar"

android:layout_width="match_parent"

android:layout_height="160dp"

android:fitsSystemWindows="true"

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

android:id="@+id/toolbar_layout"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:contentScrim="@android:color/transparent"

app:statusBarScrim="@android:color/transparent"

app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

android:id="@+id/banner"

android:layout_width="match_parent"

android:layout_height="160dp"

app:autoPlayDuration="5000"

app:indicatorMargin="50dp"

app:indicatorPosition="centerBottom"

app:indicatorShape="oval"

app:indicatorSpace="3dp"

app:scrollDuration="1100"

app:defaultImage="@mipmap/ic_launcher"

app:selectedIndicatorColor="?attr/colorPrimary"

app:selectedIndicatorHeight="6dp"

app:selectedIndicatorWidth="6dp"

app:unSelectedIndicatorColor="#99ffffff"

app:unSelectedIndicatorHeight="6dp"

app:unSelectedIndicatorWidth="6dp"

app:layout_collapseMode="parallax"

app:layout_collapseParallaxMultiplier="0.7"/>

android:id="@+id/view"

android:layout_width="match_parent"

android:layout_height="40dp"

android:background="@drawable/gradient" />

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:minHeight="?attr/actionBarSize"

android:gravity="top"

app:layout_collapseMode="pin"/>

android:id="@+id/search_tab_container"

android:layout_width="match_parent"

android:layout_height="43dp"

android:layout_marginBottom="-4dp"

android:layout_gravity="bottom">

android:layout_width="match_parent"

android:layout_height="40dp"

android:background="#5a000000"

android:layout_marginLeft="5dp"

android:layout_marginTop="3dp"

android:layout_marginBottom="-4dp"

android:layout_marginRight="5dp"/>

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="bottom"

android:layout_marginBottom="-4dp"

android:layout_marginLeft="5dp"

android:layout_marginRight="5dp"

android:orientation="horizontal">

android:id="@+id/slide_bg"

android:layout_width="120dp"

android:layout_height="43dp"

android:background="@drawable/ctrip_slide_tab"/>

android:id="@+id/rg_slide"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"

android:gravity="center"

android:layout_centerInParent="true">

android:id="@+id/rb_left"

android:background="@null"

android:textColor="@color/top_layout_sliide_text_color_selector"

android:gravity="center"

android:button="@null"

android:textSize="16dp"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:checked="false"

android:text="单程" />

android:id="@+id/rb_center"

android:background="@null"

android:textColor="@color/top_layout_sliide_text_color_selector"

android:gravity="center"

android:textSize="16dp"

android:button="@null"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:text="往返" />

android:id="@+id/rb_right"

android:background="@null"

android:button="@null"

android:textColor="@color/top_layout_sliide_text_color_selector"

android:gravity="center"

android:textSize="16dp"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:singleLine="true"

android:text="多程"

android:visibility="visible" />

android:id="@+id/top_container"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:minHeight="?attr/actionBarSize"

android:orientation="horizontal"

android:gravity="center"

android:layout_gravity="top"

app:layout_collapseMode="pin"

android:background="@color/ctirp_color_primary">

android:layout_width="261dp"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:gravity="center"

android:layout_centerInParent="true">

android:background="@drawable/title_left_shape"

android:padding="6dp"

android:textColor="@color/top_layout_text_color_selector"

android:gravity="center"

android:button="@null"

android:textSize="16dp"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:checked="true"

android:text="单程" />

android:background="@drawable/title_center_shape"

android:padding="6dp"

android:textColor="@color/top_layout_text_color_selector"

android:gravity="center"

android:textSize="16dp"

android:button="@null"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:layout_marginLeft="-1dp"

android:layout_marginRight="-1dp"

android:text="往返" />

android:background="@drawable/title_right_shape"

android:padding="6dp"

android:button="@null"

android:textColor="@color/top_layout_text_color_selector"

android:gravity="center"

android:textSize="16dp"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:singleLine="true"

android:text="多程"

android:visibility="visible" />

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:layout_behavior="@string/appbar_scrolling_view_behavior">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:src="@drawable/search_bg"

android:scaleType="fitStart"/>

当然,除了布局文件,我们在Activity里也要对一些情况进行特殊处理才能完成携程的效果.

首先,我们布局里的广告轮播用了com.yyydjk.library.BannerLayout,github上的开源项目,图片是去携程App上抓出来的。

除此之外,还需要去监听我们整体的滑动过程,通过滑动的位置来为一些控件设置Alpha值从而达到渐变隐藏和显示的效果,这里采用的是为AppBarLayout提供OnOffsetChangedListener监听,这样就可以得到竖直方向的offset

mAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

@Override

public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {

mSlideView.setAlpha(getAlpha(verticalOffset, appBarLayout.getTotalScrollRange()));

mTop.setAlpha(1.0f - getAlpha(verticalOffset, appBarLayout.getTotalScrollRange()));

}

});

}

就酱,整个仿写的过程就完成了,赶紧编译试试吧,效果还是挺好的。

交流群103791667

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
针对仿携程旅行的Vue3案例需求分,我们可以考虑以下方面: 1. 页面结构:了解携程旅行网站的整体结构和功能布局,包括首页、搜索页、详情页、订单页等。根据需求确定需要实现的页面和它们之间的关系。 2. 数据接口:携程旅行网站通常会有一些数据接口,如获取酒店列表、获取景点信息等。需要确定哪些接口是必要的,并与后端开发人员协商好接口的格式和参数。 3. 首页功能:仿携程旅行的首页通常会展示热门推荐、特价产品、城市导航等内容。需要确定如何获取这些数据,并实现相关的展示和交互逻辑。 4. 搜索功能:考虑到携程旅行网站的搜索功能,用户可以根据目的地、日期、价格等条件进行搜索。需要设计相应的搜索界面和实现搜索逻辑。 5. 详情页功能:仿携程旅行的详情页通常会展示产品的详细信息、图片轮播、用户评价等内容。需要确定如何获取产品的详细信息并展示,以及如何实现图片轮播和评价展示等功能。 6. 订单功能:用户可以在携程旅行网站上下单购买产品,需要实现相应的下单逻辑和订单管理功能。 7. 用户认证和登录功能:仿携程旅行的案例可能需要实现用户认证和登录功能,以便用户可以保存个人信息、查看订单等。 8. 响应式设计:确保页面在不同尺寸的移动设备上都能够良好地显示和交互。 通过对以上需求进行分析,可以更好地指导Vue3案例的设计和开发工作,确保最终的案例能够实现类似携程旅行网站的功能,并提供良好的用户体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值