使用CoordinatorLayout
来源:互联网 发布:mac开机黑屏文件问号 编辑:程序博客网 时间:2024/06/05 19:52
CoordinatorLayout是在 Google IO/15 大会发布的,遵循Material 风格,包含在 support Library中,结合AppbarLayout, CollapsingToolbarLayout等 可 产生各种炫酷的效果
简单的一个例子
库 compile 'com.android.support:design:24.2.1'
直接使用布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/main_home_bar"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="#ffffff">
android:id="@+id/main_home_bar"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="#ffffff">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="@mipmap/ic_launcher" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="@mipmap/ic_launcher" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/OverflowMenuStyle"
app:theme="@style/ToolbarTheme">
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/OverflowMenuStyle"
app:theme="@style/ToolbarTheme">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:id="@+id/title_model2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/app_name"
android:textColor="#ffffff"
android:textSize="20sp" />
android:id="@+id/title_model2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/app_name"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</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">
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ImageView
android:layout_width="66dp"
android:layout_height="59dp"
android:layout_gravity="center_horizontal"
android:background="@mipmap/ic_launcher" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
效果图 imageview 部分的折叠 tab部分的背景色 标题是固定在顶端的 有属性设置 简单的使用 有兴趣的可以研究下
阅读全文
0 0
- 使用CoordinatorLayout
- CoordinatorLayout使用
- CoordinatorLayout使用
- CoordinatorLayout使用
- CoordinatorLayout使用
- 使用CoordinatorLayout
- 使用CoordinatorLayout
- coordinatorlayout使用
- 使用CoordinatorLayout
- 使用CoordinatorLayout
- android CoordinatorLayout使用
- CoordinatorLayout、SwipeRefreshLayout的使用
- Android:CoordinatorLayout使用详解
- CoordinatorLayout的使用
- CoordinatorLayout的简单使用
- android CoordinatorLayout使用
- android CoordinatorLayout使用
- android CoordinatorLayout使用
- verilog时钟分频设计
- C++11特性无法在编译器上运行的解决办法
- python map,reduce,filter
- I/O多路复用之epoll学习总结
- 使用getopt模块获取命令行选项
- 使用CoordinatorLayout
- 《MD5加密工具类》
- 查询区间第k大 POJ2104 暴力 or 划分树 or 归并树
- Lua的require机制
- 没事刷刷题之三(简单英文题)I
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.jav
- 分享 50 个完整的 React Native 项目
- Eclipse报错Could not write metadata for '/RemoteSystemsTempFiles'.D:\Program Files\eclipse\workspace\.
- 配置_StatViewServlet配置