From 6bd4b41f8c7eeb112d00bc42658eace8ed3bcb85 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 23 Apr 2019 08:03:29 +0800 Subject: [PATCH] Hide Toolbar when scrolling content up. --- .../ViewSubredditDetailActivity.java | 5 - .../ViewUserDetailActivity.java | 4 - app/src/main/res/layout/activity_main.xml | 133 +++++++++--------- .../layout/activity_view_subreddit_detail.xml | 3 +- .../res/layout/activity_view_user_detail.xml | 3 +- app/src/main/res/layout/app_bar_main.xml | 51 ++++--- app/src/main/res/layout/fragment_post.xml | 8 -- 7 files changed, 97 insertions(+), 110 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java index e5f94cf3..70cdda82 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java @@ -20,7 +20,6 @@ import androidx.lifecycle.ViewModelProviders; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; import com.bumptech.glide.request.RequestOptions; -import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.chip.Chip; import com.google.android.material.snackbar.Snackbar; @@ -93,10 +92,6 @@ public class ViewSubredditDetailActivity extends AppCompatActivity { String title = "r/" + subredditName; subredditNameTextView.setText(title); - - CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.collapsing_toolbar_layout_view_subreddit_detail_activity); - collapsingToolbarLayout.setTitleEnabled(false); - Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(title); setSupportActionBar(toolbar); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java index 00b9fe4b..0fb312fb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java @@ -19,7 +19,6 @@ import androidx.lifecycle.ViewModelProviders; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; import com.bumptech.glide.request.RequestOptions; -import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.chip.Chip; import com.google.android.material.snackbar.Snackbar; @@ -90,9 +89,6 @@ public class ViewUserDetailActivity extends AppCompatActivity { String title = "u/" + userName; userNameTextView.setText(title); - CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.collapsing_toolbar_layout_view_user_detail_activity); - collapsingToolbarLayout.setTitleEnabled(false); - Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(title); setSupportActionBar(toolbar); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 13eec540..12eff6dc 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,5 @@ - + - + + + android:layout_height="wrap_content" + android:orientation="vertical"> + + + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:padding="16dp"> - - - - - - - - - - - + - - - - - - + android:layout_gravity="center_vertical" + android:text="@string/profile" + android:textColor="@android:color/black" /> - + - + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml index 5d83b5fa..5fff46ca 100644 --- a/app/src/main/res/layout/activity_view_subreddit_detail.xml +++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml @@ -8,15 +8,14 @@ tools:context=".ViewSubredditDetailActivity"> diff --git a/app/src/main/res/layout/activity_view_user_detail.xml b/app/src/main/res/layout/activity_view_user_detail.xml index ca8625d3..9bd70a72 100644 --- a/app/src/main/res/layout/activity_view_user_detail.xml +++ b/app/src/main/res/layout/activity_view_user_detail.xml @@ -8,15 +8,14 @@ tools:context=".ViewUserDetailActivity"> diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 94727b02..cfd4637b 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -11,33 +11,40 @@ android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> - + android:layout_height="match_parent" + app:titleEnabled="false" + app:layout_scrollFlags="scroll|enterAlways" + app:toolbarId="@+id/toolbar"> - + android:layout_height="wrap_content"> - + - + + + + + diff --git a/app/src/main/res/layout/fragment_post.xml b/app/src/main/res/layout/fragment_post.xml index 3b073f08..ad9e23d7 100644 --- a/app/src/main/res/layout/fragment_post.xml +++ b/app/src/main/res/layout/fragment_post.xml @@ -43,12 +43,4 @@ - -