maven { url "https://jitpack.io" }
implementation 'com.github.sovegetables.shineandroid:topnavbar:0.1.1'
<com.sovegetables.topnavbar.ActionBarView
android:id="@+id/action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
val left = TopBarItem.Builder()
.icon(R.drawable.ic_baseline_menu_24)
.listener {
toast("点击左边的Icon")
}
.build(this, 1)
val right1 = TopBarItem.Builder()
.icon(R.drawable.ic_baseline_add_circle_24)
.listener {
toast("点击右边的添加Icon")
}
.build(this, 2)
val right2 = TopBarItem.Builder()
.icon(R.drawable.ic_baseline_sms_24)
.listener {
toast("点击右边的消息Icon")
}
.visibility(TopBarItem.Visibility.GONE)
.build(this, 3)
val rights = arrayListOf<TopBarItem>()
rights.add(right1)
rights.add(right2)
val topBar = TopBar.Builder()
.title("标题1")
.left(left)
.right(right3)
.titleColor(Color.BLACK)
.topBarColorRes(R.color.colorPrimary)
.build(this)
action_bar.setUpTopBar(topBar)
action_bar.topBarUpdater
.title("更新标题1")
.titleColorRes(R.color.colorAccent)
.topBarColor(Color.BLACK)
.update()
action_bar.findRightItemUpdaterById(3)
.visibility(View.VISIBLE)
.update()
- 中间Title或者左边Title
- ActionBar右边添加icon,最多支持3个
- 动态改变ActionBar的title, 背景颜色,右上角icon可见性等