From f8c939340561b9491b4424a629c413b4393430b8 Mon Sep 17 00:00:00 2001
From: Administrator <1760316362@qq.com>
Date: Tue, 30 Jul 2019 11:02:31 +0800
Subject: [PATCH] update TitleBar
---
.../java/io/legado/app/ui/widget/TitleBar.kt | 31 ++++
.../main/res/layout/activity_book_source.xml | 25 +--
app/src/main/res/values/attrs.xml | 154 +++++++++---------
3 files changed, 124 insertions(+), 86 deletions(-)
diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
index ea0776e04..0ce45791b 100644
--- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
+++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
@@ -86,6 +86,37 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
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()) {
this.title = titleText
}
diff --git a/app/src/main/res/layout/activity_book_source.xml b/app/src/main/res/layout/activity_book_source.xml
index 0293b0fff..4069bd48a 100644
--- a/app/src/main/res/layout/activity_book_source.xml
+++ b/app/src/main/res/layout/activity_book_source.xml
@@ -1,20 +1,21 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ android:id="@+id/title_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:contentInsetStartWithNavigation="0dp"
+ app:displayHomeAsUp="true"
+ app:title="@string/book_source"/>
+ android:id="@+id/recycler_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 3033ce4a2..c782a6e9a 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -2,109 +2,115 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
\ No newline at end of file