update TitleBar

pull/32/head
Administrator 5 years ago
parent 16b4932a01
commit f8c9393405
  1. 31
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
  2. 1
      app/src/main/res/layout/activity_book_source.xml
  3. 6
      app/src/main/res/values/attrs.xml

@ -86,6 +86,37 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
this.setSubtitleTextColor(a.getColor(R.styleable.TitleBar_subtitleTextColor, -0x1)) this.setSubtitleTextColor(a.getColor(R.styleable.TitleBar_subtitleTextColor, -0x1))
} }
if (a.hasValue(R.styleable.TitleBar_contentInsetLeft)
|| a.hasValue(R.styleable.TitleBar_contentInsetRight)
) {
this.setContentInsetsAbsolute(
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetLeft, 0),
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetRight, 0)
)
}
if (a.hasValue(R.styleable.TitleBar_contentInsetStart)
|| a.hasValue(R.styleable.TitleBar_contentInsetEnd)
) {
this.setContentInsetsRelative(
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetStart, 0),
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetEnd, 0)
)
}
if (a.hasValue(R.styleable.TitleBar_contentInsetStartWithNavigation)) {
this.contentInsetStartWithNavigation = a.getDimensionPixelOffset(
R.styleable.TitleBar_contentInsetStartWithNavigation, 0
)
}
if (a.hasValue(R.styleable.TitleBar_contentInsetEndWithActions)) {
this.contentInsetEndWithActions = a.getDimensionPixelOffset(
R.styleable.TitleBar_contentInsetEndWithActions, 0
)
}
if (!titleText.isNullOrBlank()) { if (!titleText.isNullOrBlank()) {
this.title = titleText this.title = titleText
} }

@ -9,6 +9,7 @@
android:id="@+id/title_bar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:contentInsetStartWithNavigation="0dp"
app:displayHomeAsUp="true" app:displayHomeAsUp="true"
app:title="@string/book_source"/> app:title="@string/book_source"/>

@ -8,6 +8,12 @@
<attr name="titleTextColor"/> <attr name="titleTextColor"/>
<attr name="subtitleTextAppearance"/> <attr name="subtitleTextAppearance"/>
<attr name="subtitleTextColor"/> <attr name="subtitleTextColor"/>
<attr name="contentInsetEnd"/>
<attr name="contentInsetEndWithActions"/>
<attr name="contentInsetStart"/>
<attr name="contentInsetStartWithNavigation"/>
<attr name="contentInsetLeft"/>
<attr name="contentInsetRight"/>
<attr name="attachToActivity" format="boolean"/> <attr name="attachToActivity" format="boolean"/>
<attr name="displayHomeAsUp" format="boolean"/> <attr name="displayHomeAsUp" format="boolean"/>
<attr name="navigationIcon" format="reference"/> <attr name="navigationIcon" format="reference"/>

Loading…
Cancel
Save