diff --git a/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt b/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt
index 23aa760..59519c2 100644
--- a/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt
+++ b/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt
@@ -150,6 +150,20 @@ class AnimatedBottomBar @JvmOverloads constructor(
tabStyle.textSize
)
+ textMaxLines = attr.getInt(R.styleable.AnimatedBottomBar_abb_textMaxLines, tabStyle.textMaxLines)
+ textGravity = attr.getInt(R.styleable.AnimatedBottomBar_abb_textGravity, tabStyle.textGravity)
+
+ if(Build.VERSION.SDK_INT >= 23) {
+ textBreakStrategy = attr.getInt(
+ R.styleable.AnimatedBottomBar_abb_textBreakStrategy,
+ tabStyle.textBreakStrategy
+ )
+ textHyphenationFrequency = attr.getInt(
+ R.styleable.AnimatedBottomBar_abb_textHyphenationFrequency,
+ tabStyle.textHyphenationFrequency
+ )
+ }
+
// Icon
iconSize =
attr.getDimension(
@@ -962,6 +976,40 @@ class AnimatedBottomBar @JvmOverloads constructor(
applyTabStyle(BottomBarStyle.StyleUpdateType.TEXT)
}
+ var textMaxLines: Int
+ get() = tabStyle.textMaxLines
+ set(value) {
+ tabStyle.textMaxLines = value
+ applyTabStyle(BottomBarStyle.StyleUpdateType.TEXT)
+ }
+
+ var textGravity: Int
+ get() = tabStyle.textGravity
+ set(value) {
+ tabStyle.textGravity = value
+ applyTabStyle(BottomBarStyle.StyleUpdateType.TEXT)
+ }
+
+ var textHyphenationFrequency: Int
+ @RequiresApi(23)
+ get() = tabStyle.textHyphenationFrequency
+
+ @RequiresApi(23)
+ set(value) {
+ tabStyle.textHyphenationFrequency = value
+ applyTabStyle(BottomBarStyle.StyleUpdateType.TEXT)
+ }
+
+ var textBreakStrategy: Int
+ @RequiresApi(23)
+ get() = tabStyle.textBreakStrategy
+
+ @RequiresApi(23)
+ set(value) {
+ tabStyle.textBreakStrategy = value
+ applyTabStyle(BottomBarStyle.StyleUpdateType.TEXT)
+ }
+
// Icon
var iconSize
@Dimension
diff --git a/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt b/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt
index 228159a..d2c4313 100644
--- a/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt
+++ b/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt
@@ -1,7 +1,11 @@
package nl.joery.animatedbottombar
+import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.Typeface
+import android.graphics.text.LineBreaker
+import android.text.Layout
+import android.view.Gravity
import android.view.animation.Interpolator
import androidx.annotation.ColorInt
import androidx.annotation.Dimension
@@ -11,6 +15,9 @@ import nl.joery.animatedbottombar.utils.dpPx
import nl.joery.animatedbottombar.utils.spPx
object BottomBarStyle {
+ // Suppresses the warning on textBreakStrategy and textHyphenationFrequency.
+ // The values won't be used if API level < 23
+ @SuppressLint("NewApi")
data class Tab(
// Type
var selectedTabType: AnimatedBottomBar.TabType = AnimatedBottomBar.TabType.ICON,
@@ -34,6 +41,10 @@ object BottomBarStyle {
@StyleRes var textAppearance: Int = -1,
var typeface: Typeface = Typeface.DEFAULT,
var textSize: Int = 14.spPx,
+ var textMaxLines: Int = 1,
+ var textGravity: Int = Gravity.CENTER_HORIZONTAL,
+ var textBreakStrategy: Int = LineBreaker.BREAK_STRATEGY_SIMPLE,
+ var textHyphenationFrequency: Int = Layout.HYPHENATION_FREQUENCY_NONE,
// Icon
var iconSize: Int = 24.dpPx,
diff --git a/library/src/main/java/nl/joery/animatedbottombar/TabView.kt b/library/src/main/java/nl/joery/animatedbottombar/TabView.kt
index 955895a..3068702 100644
--- a/library/src/main/java/nl/joery/animatedbottombar/TabView.kt
+++ b/library/src/main/java/nl/joery/animatedbottombar/TabView.kt
@@ -136,7 +136,6 @@ internal class TabView @JvmOverloads constructor(
textView = this
ellipsize = TextUtils.TruncateAt.END
- isSingleLine = true
})
addView(BadgeView(context).apply {
@@ -287,6 +286,15 @@ internal class TabView @JvmOverloads constructor(
private fun updateText() {
textView.run {
typeface = style.typeface
+ maxLines = style.textMaxLines
+
+ if(Build.VERSION.SDK_INT >= 23) {
+ hyphenationFrequency = style.textHyphenationFrequency
+ breakStrategy = style.textBreakStrategy
+ }
+
+ gravity = style.textGravity
+
setTextSize(TypedValue.COMPLEX_UNIT_PX, style.textSize.toFloat())
}
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index 71fb458..26db45c 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -56,6 +56,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+