From d15b5ecb31db5b979778b9699eb7ebbf817fa00f Mon Sep 17 00:00:00 2001 From: Pranav Pandey Date: Wed, 11 Apr 2018 23:51:45 +0530 Subject: [PATCH] Improve collapsing app bar and header --- .../DynamicPermissionsActivity.java | 2 +- .../res/layout/ads_activity_collapsing.xml | 9 ++-- .../src/main/res/layout/ads_header_drawer.xml | 4 +- ...olbar.xml => ads_layout_header_appbar.xml} | 14 +++--- .../res/layout/ads_toolbar_collapsing.xml | 44 +++++++++++++++++++ .../src/main/res/values/dimens.xml | 18 ++++---- .../activity/CollapsingAppBarActivity.kt | 2 +- 7 files changed, 70 insertions(+), 23 deletions(-) rename dynamic-support/src/main/res/layout/{ads_layout_header_toolbar.xml => ads_layout_header_appbar.xml} (81%) create mode 100644 dynamic-support/src/main/res/layout/ads_toolbar_collapsing.xml diff --git a/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/permission/DynamicPermissionsActivity.java b/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/permission/DynamicPermissionsActivity.java index 5b47138294..026f603ef0 100644 --- a/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/permission/DynamicPermissionsActivity.java +++ b/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/permission/DynamicPermissionsActivity.java @@ -54,7 +54,7 @@ public void onClick(View v) { setAppBarBackDrop(R.drawable.ads_ic_security); - addHeader(R.layout.ads_layout_header_toolbar, true); + addHeader(R.layout.ads_layout_header_appbar, true); ((ImageView) findViewById(R.id.ads_header_toolbar_icon)) .setImageDrawable(getApplicationInfo().loadIcon(getPackageManager())); ((TextView) findViewById(R.id.ads_header_toolbar_title)) diff --git a/dynamic-support/src/main/res/layout/ads_activity_collapsing.xml b/dynamic-support/src/main/res/layout/ads_activity_collapsing.xml index d018510470..ec3fa6c286 100644 --- a/dynamic-support/src/main/res/layout/ads_activity_collapsing.xml +++ b/dynamic-support/src/main/res/layout/ads_activity_collapsing.xml @@ -40,10 +40,11 @@ android:id="@+id/ads_collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="@dimen/ads_collapsing_toolbar_height" - app:expandedTitleMarginEnd="64dp" android:clipChildren="false" - app:layout_scrollFlags="scroll|enterAlwaysCollapsed" - android:fitsSystemWindows="true"> + android:fitsSystemWindows="true" + app:expandedTitleMarginStart="@dimen/ads_toolbar_margin_start_collapsing" + app:expandedTitleMarginEnd="@dimen/ads_toolbar_inset_start_collapsing" + app:layout_scrollFlags="scroll|enterAlwaysCollapsed"> diff --git a/dynamic-support/src/main/res/layout/ads_header_drawer.xml b/dynamic-support/src/main/res/layout/ads_header_drawer.xml index 4f94b67211..2a48490120 100644 --- a/dynamic-support/src/main/res/layout/ads_header_drawer.xml +++ b/dynamic-support/src/main/res/layout/ads_header_drawer.xml @@ -36,8 +36,8 @@ diff --git a/dynamic-support/src/main/res/layout/ads_layout_header_toolbar.xml b/dynamic-support/src/main/res/layout/ads_layout_header_appbar.xml similarity index 81% rename from dynamic-support/src/main/res/layout/ads_layout_header_toolbar.xml rename to dynamic-support/src/main/res/layout/ads_layout_header_appbar.xml index 2a4e8847ce..ee043474b1 100644 --- a/dynamic-support/src/main/res/layout/ads_layout_header_toolbar.xml +++ b/dynamic-support/src/main/res/layout/ads_layout_header_appbar.xml @@ -28,11 +28,11 @@ + android:layout_width="@dimen/ads_icon_header_appbar" + android:layout_height="@dimen/ads_icon_header_appbar" + android:layout_marginRight="@dimen/ads_margin_normal" + android:layout_marginEnd="@dimen/ads_margin_normal" + android:layout_gravity="center_vertical" /> @@ -52,7 +52,7 @@ android:id="@+id/ads_header_toolbar_subtitle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:textAppearance="@style/TextAppearance.AppCompat.Body1" + android:textAppearance="@style/TextAppearance.DynamicApp.Subtitle" app:ads_colorType="tint_primary" app:ads_backgroundAware="false" /> diff --git a/dynamic-support/src/main/res/layout/ads_toolbar_collapsing.xml b/dynamic-support/src/main/res/layout/ads_toolbar_collapsing.xml new file mode 100644 index 0000000000..a69647fb6a --- /dev/null +++ b/dynamic-support/src/main/res/layout/ads_toolbar_collapsing.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dynamic-support/src/main/res/values/dimens.xml b/dynamic-support/src/main/res/values/dimens.xml index 3deae0c43d..4d8d2fd741 100644 --- a/dynamic-support/src/main/res/values/dimens.xml +++ b/dynamic-support/src/main/res/values/dimens.xml @@ -65,6 +65,9 @@ 72dp + 68dp + 20dp + @dimen/ads_toolbar_inset_start_collapsing 44dp 48dp @dimen/ads_toolbar_inset_start @@ -99,11 +102,10 @@ 32dp 160dp 200dp - 64dp - 56dp - 64dp - 60dp 20dp + 64dp + 32dp + @dimen/ads_margin_large @dimen/ads_icon_small @dimen/ads_icon_medium @dimen/ads_icon_normal @@ -111,7 +113,6 @@ @dimen/ads_icon_small 64dp @dimen/ads_icon_medium - @dimen/ads_margin_large @dimen/ads_margin_normal @dimen/ads_margin_normal @dimen/ads_margin_normal @@ -119,12 +120,15 @@ 28dp + @dimen/ads_margin_small + 56dp @dimen/ads_icon_normal 28dp 28dp 2dp + 60dp 24dp @@ -143,9 +147,6 @@ 24dp - - @dimen/ads_margin_small - @dimen/ads_icon_medium 42dp @@ -167,6 +168,7 @@ 26dp + 64dp 12dp @dimen/ads_notification_margin_vertical 16dp diff --git a/sample/src/main/java/com/pranavpandey/android/dynamic/support/sample/activity/CollapsingAppBarActivity.kt b/sample/src/main/java/com/pranavpandey/android/dynamic/support/sample/activity/CollapsingAppBarActivity.kt index bf04067361..4919025337 100644 --- a/sample/src/main/java/com/pranavpandey/android/dynamic/support/sample/activity/CollapsingAppBarActivity.kt +++ b/sample/src/main/java/com/pranavpandey/android/dynamic/support/sample/activity/CollapsingAppBarActivity.kt @@ -78,7 +78,7 @@ class CollapsingAppBarActivity : DynamicActivity() { setAppBarBackDrop(R.drawable.ads_ic_extension) // Add an optional header with an icon, title and subtitle. - addHeader(R.layout.ads_layout_header_toolbar, true) + addHeader(R.layout.ads_layout_header_appbar, true) (findViewById(R.id.ads_header_toolbar_icon) as ImageView) .setImageDrawable(applicationInfo.loadIcon(packageManager)) (findViewById(R.id.ads_header_toolbar_title) as TextView)