diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt index 266dfd8..e69a70a 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt @@ -3,10 +3,12 @@ package pl.szczodrzynski.navlib import android.content.Context import android.util.AttributeSet import android.widget.ImageView -import androidx.core.view.children import com.google.android.material.appbar.MaterialToolbar class NavToolbar : MaterialToolbar { + + var toolbar: MaterialToolbar = this + constructor(context: Context) : super(context) { create(null, 0) } @@ -27,6 +29,17 @@ class NavToolbar : MaterialToolbar { } } + override fun setSubtitle(subtitle: CharSequence?) { + if(subtitle == null || subtitle.isEmpty()) { + toolbar.setPadding(0, 0, 0, 0) + toolbarImage?.translationY = 0f + } else { + toolbar.setPadding(0, -1, 0, 5) + toolbarImage?.translationY = 6f + } + super.setSubtitle(subtitle) + } + private fun create(attrs: AttributeSet?, defStyle: Int) { } diff --git a/navlib/src/main/res/layout/nav_view.xml b/navlib/src/main/res/layout/nav_view.xml index 92b12b2..5edb9ab 100644 --- a/navlib/src/main/res/layout/nav_view.xml +++ b/navlib/src/main/res/layout/nav_view.xml @@ -48,20 +48,23 @@ android:layout_height="match_parent">