1.简介
basetitlebar是titlebar的扩展,用户可通过xml属性设置相应显示效果。
2.使用
使用方式:(因为bintray发送审核服务器问题,所以需要在项目的根目录build.gradle文件中添加,bintray审核通过后则不需添加这一句)
maven:
gradle:
compile 'com.hlq:basetitlebar:1.0.1'
3.布局中使用:
<hlq.titlebarview.BaseTitleBar android:id="@+id/tilte"
app:lefttext_is_show="true" app:righttext_is_show="true" app:centertext = "测试"
app:lefttext="返回" app:righttext="分享" android:layout_width="match_parent"
android:layout_height="50dp" />
属性较多,主要如下:
属性名 意义 默认值
lefttext 左侧文字
righttext 右侧文字
centertext 中间文字
lefttext_color 左侧文字颜色 白色
righttext_color 右侧文字颜色 白色
titlettext_color 中间文字颜色 白色
lefticon_src 左侧图标
righticon_src 右侧图标
lefttext_is_show 左侧是否显示文字 false
righttext_is_show 右侧是否显示文字 false
lefticon_is_show 左侧是否显示图片 false
righticon_is_show 右侧是否显示图片 false
titlebarback_color titlebar背景颜色 蓝色
lefttext、righttext为设置titlebar左右两边文字;
lefttext_is_show/righttext_is_show为设置左右两边文字是否显示;
lefticon、righticon、lefticon_is_show、right_is_show同上,centretext设置titlebar的标题,lefticon_src/为设置左边图标。
lefttext_color、righttext_color、titletext_color分别设置对应的颜色。
titlebarback为设置titlebar的背景颜色。不设置任何属性模式为蓝底白字。
上述代码布局效果如下:
需要注意的是,设置属性时记得对应关系,比如设置了lefttext属性就要设置lefttext_is_show为show,推荐对称设置,即左右两边设置同时显示或不显示,也可设置为图片显示。左右两侧点击事件,可在java代码中编写,如下:
4.项目地址:https://github.com/huanglinqing123/BaseTitleBar
<https://github.com/huanglinqing123/BaseTitleBar>,欢迎start和提意见。
欢迎关注技术公众号,微信号搜索ColorfulCode 代码男人
分享技术文章,投稿分享,不限技术种类,不限技术深度,让更多人因为分享而受益。
热门工具 换一换