mirror of
https://github.com/kuba2k2/NavLib.git
synced 2025-01-18 06:16:43 -06:00
Fixed cropped subtitle issue
This commit is contained in:
parent
8a707ebec7
commit
01c787405e
@ -3,10 +3,12 @@ package pl.szczodrzynski.navlib
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.view.children
|
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
|
||||||
class NavToolbar : MaterialToolbar {
|
class NavToolbar : MaterialToolbar {
|
||||||
|
|
||||||
|
var toolbar: MaterialToolbar = this
|
||||||
|
|
||||||
constructor(context: Context) : super(context) {
|
constructor(context: Context) : super(context) {
|
||||||
create(null, 0)
|
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) {
|
private fun create(attrs: AttributeSet?, defStyle: Int) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,20 +48,23 @@
|
|||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<pl.szczodrzynski.navlib.NavToolbar
|
<pl.szczodrzynski.navlib.NavToolbar
|
||||||
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
|
||||||
android:id="@+id/nv_toolbar"
|
android:id="@+id/nv_toolbar"
|
||||||
|
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="wrap_content"
|
||||||
android:background="?actionBarBackground"
|
android:background="?actionBarBackground"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:elevation="4dp"
|
android:elevation="4dp"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
app:title="@string/app_name"
|
app:title="@string/app_name"
|
||||||
|
app:titleMargin="0dp"
|
||||||
tools:targetApi="lollipop">
|
tools:targetApi="lollipop">
|
||||||
|
|
||||||
<com.mikepenz.materialdrawer.view.BezelImageView
|
<com.mikepenz.materialdrawer.view.BezelImageView
|
||||||
android:id="@+id/nv_toolbar_image"
|
android:id="@+id/nv_toolbar_image"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:layout_marginEnd="13dp"
|
android:layout_marginEnd="13dp"
|
||||||
android:layout_marginRight="13dp"
|
android:layout_marginRight="13dp"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user