Android toolbar 标题精确居中 不会因返回键偏移

1. 总的布局文件

1<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:orientation="vertical" 7 tools:context="com.gx.gxzx.ui.realtime.commonElec.CommonElecActivity"> 8 <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android" 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" 11 xmlns:app="http://schemas.android.com/apk/res-auto"> 12 <android.support.design.widget.CollapsingToolbarLayout 13 android:layout_width="match_parent" 14 app:layout_scrollFlags="scroll|enterAlways|snap" 15 android:layout_height="wrap_content"> 16 <android.support.v7.widget.Toolbar 17 android:id="@+id/my_toolbar" 18 android:paddingTop="20dp" 19 app:contentInsetStart="0dp" 20 android:layout_width="match_parent" 21 android:layout_height="wrap_content"> 22 <RelativeLayout 23 android:layout_width="match_parent" 24 android:layout_height="wrap_content"> 25 <android.support.v7.widget.AppCompatImageButton 26 android:id="@+id/my_toolbar_back" 27 android:src="@drawable/ic_back_white" 28 android:background="?controlBackground" 29 android:layout_margin="10dp" 30 android:layout_centerVertical="true" 31 android:layout_width="25dp" 32 android:layout_height="25dp" /> 33 <ImageView 34 android:id="@+id/my_toolbar_loading" 35 android:layout_centerVertical="true" 36 android:layout_toLeftOf="@+id/my_toolbar_title" 37 android:layout_width="25dp" 38 android:layout_marginRight="10dp" 39 android:layout_height="25dp" /> 40 <TextView 41 android:id="@+id/my_toolbar_title" 42 android:text="tltie" 43 android:textColor="@color/white" 44 android:textSize="@dimen/title" 45 android:gravity="center" 46 android:layout_centerInParent="true" 47 android:layout_width="wrap_content" 48 android:layout_height="wrap_content" /> 49 </RelativeLayout> 50 </android.support.v7.widget.Toolbar> 51 </android.support.design.widget.CollapsingToolbarLayout> 52 <com.gx.gxzx.widget.MyDeviceSelector 53 android:id="@+id/my_device_selector" 54 android:layout_width="match_parent" 55 android:layout_height="wrap_content"/> 56 </android.support.design.widget.AppBarLayout> 57 <android.support.v4.widget.SwipeRefreshLayout 58 android:id="@+id/swipe_refresh_layout" 59 android:layout_width="match_parent" 60 android:layout_height="match_parent" 61 app:layout_behavior="@string/appbar_scrolling_view_behavior"> 62 <android.support.v4.widget.NestedScrollView 63 android:layout_width="match_parent" 64 android:layout_weight="1" 65 android:layout_height="0dp"> 66 .... 67 </android.support.v4.widget.NestedScrollView> 68 </android.support.v4.widget.SwipeRefreshLayout> 69 70 71</android.support.design.widget.CoordinatorLayout>

#2. 要点 ##2.1 app:contentInsetStart="0dp"

会使toolbar里面的View会扩充到左右,不会有间隙。

2.2 android:background="?controlBackground"

这个点击效果不错,圆形的灰色背景

2.3 下拉刷新

SwipeRefreshLayout 要包裹着NestedScrollView才会有下拉效果

2.4 ActionMenuView

ActionMenuView 可以添加菜单按钮

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

swap空间的增减方法

(1)增大swap空间去激活swap交换区:swapoff v /dev/vg00/lvswap扩展交换lv:lvextend L 10G /dev/vg00/lvswap重新生成swap交换区:mkswap /dev/vg00/lvswap激活新生成的交换区:swapon v /dev/vg00/lvswap

Java获得今日零时零分零秒的时间(Date型)

publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS

Python之time模块的时间戳、时间字符串格式化与转换

Python处理时间和时间戳的内置模块就有time,和datetime两个,本文先说time模块。关于时间戳的几个概念时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。时间元组(struct_time),包含9个元素。 time.struct_time(tm_y

Android toolbar 标题精确居中 不会因返回键偏移 - HelloWorld