1. 总的布局文件
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:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways|snap"
android:layout_height="wrap_content">
android:id="@+id/my_toolbar"
android:paddingTop="20dp"
app:contentInsetStart="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="wrap_content">
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" />
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" />
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" />
android:id="@+id/my_device_selector"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
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:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp">
....
#2. 要点 ##2.1 app:contentInsetStart="0dp"
会使toolbar里面的View会扩充到左右,不会有间隙。
2.2 android:background="?controlBackground"
这个点击效果不错,圆形的灰色背景
2.3 下拉刷新
SwipeRefreshLayout 要包裹着NestedScrollView才会有下拉效果
2.4 ActionMenuView
ActionMenuView 可以添加菜单按钮