Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Added lift on scroll for Appbars 🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
Rminsh committed Sep 3, 2020
1 parent 669e189 commit 076fc5c
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.widget.NestedScrollView;

import android.content.Context;
import android.graphics.Color;
Expand All @@ -31,7 +32,6 @@
import android.view.MotionEvent;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;

import com.androidnetworking.AndroidNetworking;
Expand Down Expand Up @@ -69,7 +69,7 @@

public class DetailActivity extends AppCompatActivity {

ScrollView scrollView;
NestedScrollView scrollView;
View parent_chart_frame;
LineChart chart;
ProgressBar table_progressbar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected void onCreate(Bundle savedInstanceState) {
toolbar = findViewById(R.id.toolbar);
toolbar.inflateMenu(R.menu.main_menu);

recycler_view = findViewById(R.id.classroom_news_rcv);
recycler_view = findViewById(R.id.price_rcv);
status_layout = findViewById(R.id.status_layout);
status_animation = findViewById(R.id.status_animation);
status_text = findViewById(R.id.status_text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_overview, container, false);
recycler_view = root.findViewById(R.id.classroom_news_rcv);
recycler_view = root.findViewById(R.id.price_rcv);
recycler_view.setHasFixedSize(true);

swipeRefreshLayout = root.findViewById(R.id.main_page_refresh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_overview, container, false);
recycler_view = root.findViewById(R.id.classroom_news_rcv);
recycler_view = root.findViewById(R.id.price_rcv);
recycler_view.setHasFixedSize(true);

swipeRefreshLayout = root.findViewById(R.id.main_page_refresh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_overview, container, false);
recycler_view = root.findViewById(R.id.classroom_news_rcv);
recycler_view = root.findViewById(R.id.price_rcv);
recycler_view.setHasFixedSize(true);

swipeRefreshLayout = root.findViewById(R.id.main_page_refresh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_overview, container, false);
recycler_view = root.findViewById(R.id.classroom_news_rcv);
recycler_view = root.findViewById(R.id.price_rcv);
recycler_view.setHasFixedSize(true);

swipeRefreshLayout = root.findViewById(R.id.main_page_refresh);
Expand Down
28 changes: 22 additions & 6 deletions app/src/main/res/layout/activity_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,38 @@
~ along with Sarrafi. If not, see <https://www.gnu.org/licenses/>.
-->

<LinearLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="rtl"
android:orientation="vertical"
tools:context=".activity.DetailActivity">

<include layout="@layout/toolbar"/>
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:liftOnScroll="true"
app:liftOnScrollTargetViewId="@id/detail_scrollview"
android:overScrollMode="always">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>

</com.google.android.material.appbar.AppBarLayout>

<ScrollView
<androidx.core.widget.NestedScrollView
android:id="@+id/detail_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<include layout="@layout/content_detail" />
</ScrollView>
</androidx.core.widget.NestedScrollView>

</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
android:layout_height="match_parent">

<com.shalchian.sarrafi.utils.AutoFitRecyclerView
android:id="@+id/classroom_news_rcv"
android:id="@+id/price_rcv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/activity_main_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:elevation="0dp">
app:liftOnScroll="true"
app:liftOnScrollTargetViewId="@id/price_rcv"
android:overScrollMode="always" >

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_overview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
android:layout_height="match_parent">

<com.shalchian.sarrafi.utils.AutoFitRecyclerView
android:id="@+id/classroom_news_rcv"
android:id="@+id/price_rcv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:columnWidth="@dimen/column_width"
android:padding="@dimen/activity_horizontal_margin"/>
android:padding="@dimen/activity_horizontal_margin" />

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
34 changes: 0 additions & 34 deletions app/src/main/res/layout/toolbar.xml

This file was deleted.

0 comments on commit 076fc5c

Please sign in to comment.