<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.gx.gxzx.ui.realtime.commonElec.CommonElecActivity"> <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.design.widget.CollapsingToolbarLayout android:layout_width="match_parent" app:layout_scrollFlags="scroll|enterAlways|snap" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:paddingTop="20dp" app:contentInsetStart="0dp" android:layout_width="match_parent" android:layout_height="wrap_content"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatImageButton android:id="@+id/my_toolbar_back" android:src="@drawable/ic_back_white" android:background="?controlBackground" android:layout_margin="10dp" android:layout_centerVertical="true" android:layout_width="25dp" android:layout_height="25dp" /> <ImageView android:id="@+id/my_toolbar_loading" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/my_toolbar_title" android:layout_width="25dp" android:layout_marginRight="10dp" android:layout_height="25dp" /> <TextView android:id="@+id/my_toolbar_title" android:text="tltie" android:textColor="@color/white" android:textSize="@dimen/title" android:gravity="center" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout> </android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> <com.gx.gxzx.widget.MyDeviceSelector android:id="@+id/my_device_selector" android:layout_width="match_parent" android:layout_height="wrap_content"/> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_weight="1" android:layout_height="0dp"> .... </android.support.v4.widget.NestedScrollView> </android.support.v4.widget.SwipeRefreshLayout> </android.support.design.widget.CoordinatorLayout>
#2. 要點 ##2.1 app:contentInsetStart="0dp"android
會使toolbar裏面的View會擴充到左右,不會有間隙。app
這個點擊效果不錯,圓形的灰色背景佈局
SwipeRefreshLayout 要包裹着NestedScrollView纔會有下拉效果ui
ActionMenuView 能夠添加菜單按鈕code