zoukankan      html  css  js  c++  java
  • CoordinatorLayout学习笔记

    CoordinatorLayout是一个增强型的FrameLayout。它的作用有两个

    1. 作为一个布局的根布局
    2. 最为一个为子视图之间相互协调手势效果的一个协调布局

    代码如下:

    <?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:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways" />
    
            <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabGravity="fill" />
    
    
        </android.support.design.widget.AppBarLayout>
    
        <!--可滑动的布局内容-->
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    
        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_discuss"
            android:layout_gravity="bottom|end"/>
    
    
    </android.support.design.widget.CoordinatorLayout>

    因为这是一个FrameLayout,所以在布局的时候app:layout_behavior="@string/appbar_scrolling_view_behavior"非常重要,不然就黏到一块去了

  • 相关阅读:
    【转】一句话设计模式
    【转】Bad Smell(代码的坏味道)
    【转】[重构]Primitive Obsession
    【转】22种代码的坏味道,一句话概括
    【转】C#中的implicit 和 explicit
    【转】100本最棒的英文侦探小说
    [转]Visual Studio调试之符号文件
    【转】简要分析unity3d中剪不断理还乱的yield
    apache https配置步骤
    apache https配置步骤
  • 原文地址:https://www.cnblogs.com/i-love-kobe/p/5554619.html
Copyright © 2011-2022 走看看