Procházet zdrojové kódy

[검색][Common] 검색 결과 레이아웃 수정

Hasemi před 6 roky
rodič
revize
f12adc5606

+ 6 - 45
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/SearchResultFragment.java

@@ -7,14 +7,11 @@ import android.graphics.Rect;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.support.constraint.ConstraintLayout;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.Transformation;
 
 import java.util.List;
 
@@ -89,12 +86,6 @@ public class SearchResultFragment extends FragmentBase<SearchResultPresenter> im
 
     recyclerViewResultContents = findViewById(R.id.recycler_view_search_result);
     recyclerViewResultContents.setLayoutManager(new LinearLayoutManager(getContext()));
-    recyclerViewResultContents.addOnScrollListener(new RecyclerView.OnScrollListener() {
-      @Override
-      public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
-        startAnimation(dy);
-      }
-    });
 
     imageFilter = findViewById(R.id.image_filter);
     imageFilter.setOnClickListener(v -> {
@@ -149,12 +140,12 @@ public class SearchResultFragment extends FragmentBase<SearchResultPresenter> im
   @Override
   public void setVisibleCategory(boolean isVisible) {
     containerCategory.setVisibility(isVisible ? View.VISIBLE : View.GONE);
-    recyclerViewResultContents.setPadding(
-      recyclerViewResultContents.getPaddingLeft(),
-      isVisible ? ResourceUtil.dpToPx(40) : ResourceUtil.dpToPx(5),
-      recyclerViewResultContents.getPaddingRight(),
-      recyclerViewResultContents.getPaddingBottom()
-    );
+//    recyclerViewResultContents.setPadding(
+//      recyclerViewResultContents.getPaddingLeft(),
+//      isVisible ? ResourceUtil.dpToPx(40) : ResourceUtil.dpToPx(5),
+//      recyclerViewResultContents.getPaddingRight(),
+//      recyclerViewResultContents.getPaddingBottom()
+//    );
   }
 
   @Override
@@ -180,34 +171,4 @@ public class SearchResultFragment extends FragmentBase<SearchResultPresenter> im
     }
   }
 
-  private void startAnimation(int dy) {
-
-    if (dy > 20) {
-      Animation animation = new Animation() {
-        @Override
-        protected void applyTransformation(float interpolatedTime, Transformation t) {
-          ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) containerCategory.getLayoutParams();
-          layoutParams.topMargin = 0;
-          containerCategory.setLayoutParams(layoutParams);
-        }
-      };
-
-      animation.setDuration(500);
-      containerCategory.startAnimation(animation);
-    }
-    else if (dy < -20) {
-      Animation animation = new Animation() {
-        @Override
-        protected void applyTransformation(float interpolatedTime, Transformation t) {
-          ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) containerCategory.getLayoutParams();
-          layoutParams.topMargin = ResourceUtil.dpToPx(9);
-          containerCategory.setLayoutParams(layoutParams);
-        }
-      };
-
-      animation.setDuration(500);
-      containerCategory.startAnimation(animation);
-    }
-
-  }
 }

+ 93 - 53
app/src/main/res/layout/fragment_search_result.xml

@@ -30,70 +30,110 @@
       app:layout_constraintTop_toTopOf="parent"/>
   </android.support.constraint.ConstraintLayout>
 
-  <android.support.constraint.ConstraintLayout
-    android:id="@+id/container_search_result"
+  <android.support.design.widget.CoordinatorLayout
     android:layout_width="match_parent"
     android:layout_height="0dp"
-    android:background="@color/CFFFFFF"
+    app:layout_constrainedHeight="true"
     app:layout_constraintBottom_toBottomOf="parent"
-    app:layout_constraintTop_toTopOf="@id/container_category">
+    app:layout_constraintTop_toBottomOf="@+id/container_top">
 
-    <android.support.v7.widget.RecyclerView
-      android:id="@+id/recycler_view_search_result"
+    <android.support.design.widget.AppBarLayout
       android:layout_width="match_parent"
-      android:layout_height="0dp"
-      android:clipToPadding="false"
-      android:paddingTop="40dp"
-      android:paddingBottom="35dp"
-      app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintTop_toTopOf="parent"/>
-  </android.support.constraint.ConstraintLayout>
+      android:layout_height="wrap_content"
+      android:background="@color/CFFFFFF"
+      app:elevation="0dp"
+      >
 
-  <android.support.constraint.ConstraintLayout
-    android:id="@+id/container_category"
-    android:layout_width="match_parent"
-    android:layout_height="35dp"
-    android:layout_marginTop="9dp"
-    android:background="@color/CFFFFFF"
-    app:layout_constraintTop_toBottomOf="@id/container_top">
+      <android.support.design.widget.CollapsingToolbarLayout
+        android:id="@+id/collapsing_tool_bar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/CFFFFFF"
+        app:layout_scrollFlags="scroll|exitUntilCollapsed">
 
-    <android.support.v7.widget.RecyclerView
-      android:id="@+id/recycler_view_category"
-      android:layout_width="0dp"
-      android:layout_height="wrap_content"
-      android:clipToPadding="false"
-      android:paddingStart="17dp"
-      android:paddingEnd="80dp"
-      app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintEnd_toEndOf="parent"
-      app:layout_constraintStart_toStartOf="parent"
-      app:layout_constraintTop_toTopOf="parent"/>
+        <android.support.v7.widget.Toolbar
+          android:id="@+id/toolbar_invisible"
+          android:layout_width="match_parent"
+          android:layout_height="35dp"
+          android:layout_gravity="center"
+          android:background="@null"
+          android:visibility="invisible"
+          app:elevation="0dp"
+          app:layout_scrollFlags="scroll"
+          />
 
-    <View
-      android:layout_width="28dp"
-      android:layout_height="35dp"
-      android:background="@drawable/rectangle_cffffff_gradation"
-      app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintEnd_toStartOf="@+id/image_filter"/>
+        <LinearLayout
+          android:id="@+id/container_category"
+          android:layout_width="match_parent"
+          android:layout_height="35dp"
+          android:layout_marginTop="9dp"
+          android:background="@color/CFFFFFF"
+          android:orientation="vertical"
+          app:layout_collapseMode="pin"
+          app:layout_constraintTop_toBottomOf="@id/container_top">
+
+          <android.support.v7.widget.RecyclerView
+            android:id="@+id/recycler_view_category"
+            android:layout_width="match_parent"
+            android:layout_height="35dp"
+            android:clipToPadding="false"
+            android:paddingStart="17dp"
+            android:paddingEnd="80dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"/>
+
+          <View
+            android:layout_width="28dp"
+            android:layout_height="35dp"
+            android:background="@drawable/rectangle_cffffff_gradation"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toStartOf="@+id/image_filter"/>
+
+          <ImageView
+            android:id="@+id/image_filter"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="17dp"
+            android:background="@color/CFFFFFF"
+            android:padding="8dp"
+            android:scaleType="center"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:srcCompat="@drawable/ic_filter_de_copy_4"/>
+
+          <View
+            android:layout_width="18dp"
+            android:layout_height="35dp"
+            android:background="@color/CFFFFFF"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toEndOf="@+id/image_filter"/>
+        </LinearLayout>
+      </android.support.design.widget.CollapsingToolbarLayout>
+    </android.support.design.widget.AppBarLayout>
 
-    <ImageView
-      android:id="@+id/image_filter"
-      android:layout_width="wrap_content"
+    <android.support.constraint.ConstraintLayout
+      android:id="@+id/container_search_result"
+      android:layout_width="match_parent"
       android:layout_height="wrap_content"
-      android:layout_marginEnd="17dp"
-      android:padding="8dp"
-      android:scaleType="center"
       android:background="@color/CFFFFFF"
+      android:orientation="vertical"
+      app:layout_behavior="@string/appbar_scrolling_view_behavior"
       app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintEnd_toEndOf="parent"
-      app:srcCompat="@drawable/ic_filter_de_copy_4"/>
+      app:layout_constraintTop_toBottomOf="@id/container_category"
+      tools:background="@color/CF6F6F6">
 
-    <View
-      android:layout_width="18dp"
-      android:layout_height="35dp"
-      android:background="@color/CFFFFFF"
-      app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintStart_toEndOf="@+id/image_filter"
-      app:layout_constraintEnd_toEndOf="parent"/>
-  </android.support.constraint.ConstraintLayout>
+      <android.support.v7.widget.RecyclerView
+        android:id="@+id/recycler_view_search_result"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:clipToPadding="false"
+        android:paddingTop="5dp"
+        android:paddingBottom="@dimen/action_bar_height"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintTop_toTopOf="parent"/>
+    </android.support.constraint.ConstraintLayout>
+  </android.support.design.widget.CoordinatorLayout>
 </android.support.constraint.ConstraintLayout>