Customize your toolbar with beautiful style for your Android project
- Support center titleText and titleIcon
- Support change left and right button icon
- Support change background with color code and drawable with image, normal selector and gradient
- Support change visibility of left button , right button and title icon
- Support using with CoordinatorLayout to handle scroll event
- Supprot custom status bar with gradient color
- Automatically hide original actionbar
- No need to call showing method
- Easy to use
dependencies {
implementation 'com.github.chivorns:smarttoolbar:1.0.12'
}<com.chivorn.smarttoolbar.SmartToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp" /><com.chivorn.smarttoolbar.SmartToolbar
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimary"
app:smtb_leftBtnIcon="@drawable/ic_arrow_back_white_24dp"
app:smtb_rightBtnIcon="@drawable/ic_close_white_24dp"
app:smtb_showLeftBtn="true"
app:smtb_showRightBtn="true"
app:smtb_showTitleIcon="false"
app:smtb_titleColor="#f1ecec"
app:smtb_titleIcon="@drawable/title_icon"
app:smtb_titleText="Sample Title Text"
app:smtb_statusBarColor="@drawable/smart_toolbar_bg_gradient"
app:smtb_titleTextSize="15sp"
app:smtb_leftBtnIconWidth="50dp"
app:smtb_leftBtnIconHeight="30dp"
app:smtb_rightBtnIconWidth="50dp"
app:smtb_rightBtnIconHeight="30dp"
app:smtb_titleIconWidth="50dp"
app:smtb_titleIconHeight="30dp"/>// TODO: setTitleText
smartToolbar.setTitleText("New Title Text");// TODO: setTitleTextColor
smartToolbar.setTitleTextColor(getResources().getColor(R.color.colorAccent)); // or
smartToolbar.setTitleTextColor(Color.YELLOW);// TODO: setShowTitleIcon & setTitleIcon
smartToolbar.setShowTitleIcon(true);
smartToolbar.setTitleIcon(getResources().getDrawable(R.drawable.ic_close_white_24dp));// TODO: setBackgroundColor & setBackgroundDrawable
smartToolbar.setBackground(getResources().getDrawable(R.drawable.smart_toolbar_bg_gradient)); // or
smartToolbar.setBackgroundColor(Color.YELLOW);// TODO: setVisibility of left and right button
smartToolbar.setShowLeftButton(true);
smartToolbar.setShowRightButton(true);// TODO: setIcon to left and right button
smartToolbar.setLeftButtonIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp));
smartToolbar.setRightButtonIcon(getResources().getDrawable(R.drawable.ic_close_white_24dp));// TODO: show custom status bar
smartToolbar.showCustomStatusBar(this);// TODO: set status bar color
smartToolbar.setStatusBarColor(getResources().getDrawable(R.drawable.smart_toolbar_bg_gradient)); // or
smartToolbar.setStatusBarColor(Color.BLUE);// TODO: Set title text size
smartToolbar.setTitleTextSize(15);// TODO: Set layout width & height for left button
smartToolbar.setLeftButtonIconWidth(50);
smartToolbar.setLeftButtonIconHeight(30);// TODO: Set layout width & height for right button
smartToolbar.setRightButtonIconWidth(50);
smartToolbar.setRightButtonIconHeight(30);// TODO: Set layout width & height for title icon
smartToolbar.setTitleIconWidth(50);
smartToolbar.setTitleIconHeight(30);// TODO: setTitleText
smartToolbar?.setTitleText("New Title Text")// TODO: setTitleTextColor
smartToolbar?.setTitleTextColor(resources.getColor(R.color.colorAccent)) // or
smartToolbar?.setTitleTextColor(Color.YELLOW)// TODO: setShowTitleIcon & setTitleIcon
smartToolbar?.setShowTitleIcon(true)
smartToolbar?.setTitleIcon(resources.getDrawable(R.drawable.ic_close_white_24dp))// TODO: setBackgroundColor & setBackgroundDrawable
smartToolbar?.background = resources.getDrawable(R.drawable.smart_toolbar_bg_gradient) // or
smartToolbar?.setBackgroundColor(Color.YELLOW)// TODO: setVisibility of left and right button
smartToolbar?.setShowLeftButton(true)
smartToolbar?.setShowRightButton(true)// TODO: setIcon to left and right button
smartToolbar?.setLeftButtonIcon(resources.getDrawable(R.drawable.ic_arrow_back_white_24dp))
smartToolbar?.setRightButtonIcon(resources.getDrawable(R.drawable.ic_close_white_24dp))// TODO: show custom status bar
smartToolbar?.showCustomStatusBar(this);// TODO: set status bar color
smartToolbar?.setStatusBarColor(getResources().getDrawable(R.drawable.smart_toolbar_bg_gradient)); // or
smartToolbar?.setStatusBarColor(Color.BLUE);// TODO: Set title text size
smartToolbar?.setTitleTextSize(15);// TODO: Set layout width & height for left button
smartToolbar?.setLeftButtonIconWidth(50);
smartToolbar?.setLeftButtonIconHeight(30);// TODO: Set layout width & height for right button
smartToolbar?.setRightButtonIconWidth(50);
smartToolbar?.setRightButtonIconHeight(30);// TODO: Set layout width & height for title icon
smartToolbar?.setTitleIconWidth(50);
smartToolbar?.setTitleIconHeight(30);