版权声明:本文为xing_star原创文章,转载请注明出处!

本文同步自http://javaexception.com/archives/206

Android TitleBar推荐

这段时间在帮别人写一个App,为了加快进度,就引入了一些开源库,其中一个是TitleBar,Github上的地址是  https://github.com/loperSeven/TitleBar , slogan是满足各种日常使用的标题栏,不要让你的时间浪费在写标题栏上。听起来很不错。
 
在build.gradle里面引入远程依赖
implementation 'com.github.loperSeven:TitleBar:1.0.3'
 
在activity或者是fragment的xml布局里面只需要使用TitleBar就可以了,如<com.loper7.layout.TitleBar
android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    tl:tBackgroundColor="@color/colorPrimary"
    tl:tTitleText="活动"
    tl:tTitleTextColor="@color/black"
    tl:tCenterTitle="true"
    tl:tTitleTextBold="true"
    tl:tTitleTextSize="18sp" />

 

上面基本上默认的配置,如果需要设置左边的返回箭头,可以使用tBackImage来设置箭头图标。
其他的属性用法,可以参考文档或者是源码,比较简单。
这样后续就不用重复的写titleBar了。