Android 标题栏封装,方便使用
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
dependencies {
compile 'com.github.EthanCo:TitleBar:1.0.6'
}
在布局中添加TitleBar即可
<com.ethanco.titlebar.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/colorAccent"
app:bottom_divider_color="#000000"
app:bottom_divider_visible="true"
app:leftIc="@drawable/ic_back_arrow"
app:leftIc_LeftPadding="16dp"
app:leftIc_RightPadding="8dp"
app:leftText="返回"
app:bar_text_color="#FFF"
app:title_textSize="20sp"
app:common_textSize="16sp"
app:title="标题"> | 属性 | 说明 |
|---|---|
| title | 标题 |
| title_textSize | 标题字体大小 |
| common_textSize | 其他字体大小 |
| bar_text_color | 文字颜色 |
| leftText | 左边的文字 |
| leftIc | 左边的图片 |
| leftText_LeftPadding | 左边的文字的leftPadding |
| leftText_RightPadding | 左边的文字的rightPadding |
| leftIc_LeftPadding | 左边的图片的leftPadding |
| leftIc_RightPadding | 左边的图片的rightPadding |
| rightText | 右边的文字 |
| rightIc | 右边的图片 |
| rightText_LeftPadding | 右边的文字的leftPadding |
| rightText_RightPadding | 右边的文字的rightPadding |
| rightIc_LeftPadding | 右边的图片的leftPadding |
| rightIc_RightPadding | 右边的图片的rightPadding |
| bottom_divider_color | 底部divider颜色 |
| bottom_divider_visible | 底部divider是否可见 |
| left_padding | TitleBar左边的Padding |
| right_padding | TitleBar右边的Padding |
设置左边的OnClick监听事件
设置右边的OnClick监听事件
设置标题
设置左边文字
设置右边文字
设置左边文字是否显示
获取左边的TextView
设置右边的TextView是否显示
获取右边的TextView
设置左边的ImageView src
设置左边的ImageVi 是否可见
获取左边的ImageView
设置右边的ImageView
设置右边的ImageView 是否可见
获取右边的ImageView
