64、具有过渡动画效果的布局Layout( 2 )
【 CoordinatorLayout-与手势完美结合的滑动视图 】

【 AppBarLayout-可以随手势滑动的AppBar 】
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"> <!--
使用 Toolbar 作为一个标题栏 app:layout_scrollFlags="scroll|enterAlways":
当向上混动的时候,Toolbar会移出屏幕,只要向下滑动,就会显示Toolbar。 app:layout_scrollFlags="scroll|enterAlwaysCollapsed":
当向上混动的时候,Toolbar会移出屏幕,向下滑动时,滑动到第一个的时候才会显示Toolbar。 app:layout_scrollFlags="scroll|exitUntilCollapsed":
不管向上还是向下移动,Toolbar都不会滑出屏幕。
另外:如果加上,android:minHeight="20dp"的时候。
当向上滑动时候,Toolbar移出屏幕,直到变成最小高度,
向下滑动时,滑动到第一个的时候才会显示Toolbar
-->
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#77db93"
android:minHeight="20dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
</android.support.design.widget.AppBarLayout> <!-- 与手势完美结合的滑动视图 -->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
............
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView> <android.support.design.widget.FloatingActionButton
android:id="@+id/fab_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="10dp"
android:src="@drawable/ic_launcher"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
<resources>
<!-- values/styles.xml -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
package com.example.com.designdemo; import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View; public class MainActivity2 extends AppCompatActivity {
private FloatingActionButton fab_btn = null;
private CoordinatorLayout root_layout = null;
private Toolbar toolbar = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2); toolbar = (Toolbar) this.findViewById(R.id.toolbar);
setSupportActionBar(toolbar); root_layout = (CoordinatorLayout) this.findViewById(R.id.root_layout);
fab_btn = (FloatingActionButton) this.findViewById(R.id.fab_btn);
fab_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(root_layout, "我出来了", Snackbar.LENGTH_LONG)
.setAction("知道了", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
}).show();
}
}); }
}
使用 Toolbar 作为一个标题栏
app:layout_scrollFlags="scroll|enterAlways":
当向上混动的时候,Toolbar会移出屏幕,只要向下滑动,就会显示Toolbar。
app:layout_scrollFlags="scroll|enterAlwaysCollapsed":
当向上混动的时候,Toolbar会移出屏幕,向下滑动时,滑动到第一个的时候才会显示Toolbar。
app:layout_scrollFlags="scroll|exitUntilCollapsed":
不管向上还是向下移动,Toolbar都不会滑出屏幕。
另外:如果加上,android:minHeight="20dp"的时候。当向上滑动时候,Toolbar移出屏幕,直到变成最小高度,
向下滑动时,滑动到第一个的时候才会显示Toolbar
【 Collapsing Toolbars-可以伸缩的ToolBar 】



1、activity_main2.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <!--
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
把文字颜色设置成白色。
-->
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!--
app:contentScrim="#77db93" 滑动到顶部,图片背景变成Toolbar条。
-->
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="#77db93"
app:expandedTitleMarginStart="80dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_01"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.8"/> <!-- android:background="#77db93" -->
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="20dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout> <!-- 与手势完美结合的滑动视图 -->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
...............
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView> <android.support.design.widget.FloatingActionButton
android:id="@+id/fab_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="10dp"
android:src="@drawable/ic_launcher"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
2、MainActivity2.xml
package com.example.com.designdemo; import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View; public class MainActivity2 extends AppCompatActivity {
private FloatingActionButton fab_btn = null;
private CoordinatorLayout root_layout = null;
private CollapsingToolbarLayout collapsingToolbarLayout = null;
private Toolbar toolbar = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2); toolbar = (Toolbar) this.findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); collapsingToolbarLayout = (CollapsingToolbarLayout)this.findViewById(R.id.collapsingToolbarLayout);
collapsingToolbarLayout.setTitle("标题文字内容"); root_layout = (CoordinatorLayout) this.findViewById(R.id.root_layout);
fab_btn = (FloatingActionButton) this.findViewById(R.id.fab_btn);
fab_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(root_layout, "我出来了", Snackbar.LENGTH_LONG)
.setAction("知道了", new View.OnClickListener() {
@Override
public void onClick(View v) {}
}).show();
}
});
}
}
3、styles.xml
<resources>
<!-- values/styles.xml -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
DEMO完整下载地址:http://download.csdn.net/detail/androidsj/9304305
64、具有过渡动画效果的布局Layout( 2 )的更多相关文章
- 63、具有过渡动画效果的布局Layout
下面,下来看一个Demo的效果,代码如下: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android ...
- 067——VUE中vue-router之使用transition设置酷炫的路由组件过渡动画效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- react过渡动画效果的实现,react-transition-group
本文介绍react相关的过渡动画效果的实现 有点类似vue的transition组件,主要用于组件mount和unmount之前切换时应用动画效果 安装 cnpm install react-tran ...
- vue过渡动画效果
1 过渡基础 1.1 过渡的方式 Vue 在插入.更新或者移除 DOM 时,提供多种不同方式的应用过渡效果. 包括以下工具: 在 CSS 过渡和动画中自动应用 class 可以配合使用第三方 CSS ...
- CSS中的变形、过渡、动画效果
一.变形 .过渡效果 1:元素平移 x方向 y方向 transform:translate(100px 100px); 2:过渡动画效果 a:什么属性参与过渡效果 b:过渡时间 c:过渡的效果 值包含 ...
- 【Android UI设计与开发】第03期:引导界面(三)仿微信引导界面以及动画效果
基于前两篇比较简单的实例做铺垫之后,这一篇我们来实现一个稍微复杂一点的引导界面的效果,当然也只是稍微复杂了一点,对于会的人来说当然还是so easy!正所谓会者不难,难者不会,大概说的就是这个意思了吧 ...
- app引导页(背景图片切换加各个页面动画效果)
前言:不知不觉中又加班到了10点半,整个启动页面做了一天多的时间,一共有三个页面,每个页面都有动画效果,动画效果调试起来麻烦,既要跟ios统一,又要匹配各种不同的手机,然后产品经理还有可能在中途改需求 ...
- Windows Store App 过渡动画
Windows Store App 过渡动画 在开发Windows应用商店应用程序时,如果希望界面元素进入或者离开屏幕时显得自然和流畅,可以为其添加过渡动画.过渡动画能够及时地提示用户屏幕所发 ...
- Swift - 动画效果的实现方法总结(附样例)
在iOS中,实现动画有两种方法.一个是统一的animateWithDuration,另一个是组合出现的beginAnimations和commitAnimations.这三个方法都是类方法. 一,使用 ...
随机推荐
- Drupal启动阶段之四:系统变量
Drupal的系统变量是指保存在后台数据库variable表中的一些参数设置,透过variable_get()和variable_set()存取: 先看一看_drupal_bootstrap_vari ...
- iOS 移动端生成工具开发
代码地址如下:http://www.demodashi.com/demo/11284.html 一.准备工作 编译环境 xcode 用于生成冗余架构代码, 实现生成零耦合架构 二.程序实现 上个月的一 ...
- 对oracle数字类型的研究
Oracle的数字类型主要有number,binary_float,binary_double三类,其他的像int,number(p,s)等等大多数都是由这些引申出来的.这部分的理解主要来自oracl ...
- mongodb - Replication Set搭建过程
1.创建目录 mkdir -p /mongodb/data/r1 mkdir -p /mongodb/data/r2 mkdir -p /mongodb/data/r3 mkdir -p /mongo ...
- MVC中Area的另一种用法
[摘要]本文只是为一行代码而分享 context.MapRoute("API", "api/{controller}/{action}", new { }, n ...
- MVC :“已添加了具有相同键的项”
最近将一个项目从ASP.NET MVC 3升级至刚刚发布的ASP.NET MVC 5.1,升级后发现一个ajax请求出现了500错误,日志中记录的详细异常信息如下: System.ArgumentEx ...
- 让python cookie支持特殊字符
让python cookie支持特殊字符 先对cookie做下简单的介绍 cookie的作用: tcp协议能够通过三次握手建立连接.client发送的多次请求能够通过句柄维护同一个连接.可是http协 ...
- Top 10 Project Management Software
- linux一条命令添加一个root级别账户并设置密码
内网机器提权添加账户,无回显,设置密码就不好弄,下面就是添加一个root级别的账户并设置密码的命令 ? 1 useradd -p `openssl passwd -1 -salt 'lsof' a ...
- 380. Intersection of Two Linked Lists【medium】
Write a program to find the node at which the intersection of two singly linked lists begins. Notice ...