AppBarLayout 안에 LinearLayout의 빨간색으로 옵션을 지정하면 해당 영역 만큼 스와이프로 숨길 수 있음


<android.support.design.widget.AppBarLayout

    android:id="@+id/appBarLayout"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    app:elevation="0dp">


    <LinearLayout

        android:id="@+id/layout"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="10dp"

        android:layout_marginLeft="10dp"

        android:layout_marginRight="10dp"

        android:layout_marginTop="10dp"

        android:background="@drawable/search_drawable"

        app:layout_scrollFlags="scroll|enterAlways">


</android.support.design.widget.AppBarLayout>


코드에서 제어하기 위해서는


AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id. appBarLayout);

LinearLayout layout = (LinearLayout) findViewById(R.id. layout);

AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) layout.getLayoutParams();


선언 후 appBarLayout을 찾아온 후

params.setScrollFlags(0)을하면 스크롤을 해도 숨겨지지 않는다 반대로

params.setScrollFlags(1)로 적용하면 원래의 기능을 사용할수 있음

intcomputeHorizontalScrollExtent()

Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range.

intcomputeHorizontalScrollOffset()

Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range.

intcomputeHorizontalScrollRange()

Compute the horizontal range that the horizontal scrollbar represents.

intcomputeVerticalScrollExtent()

Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.

intcomputeVerticalScrollOffset()

Compute the vertical offset of the vertical scrollbar's thumb within the vertical range.

intcomputeVerticalScrollRange()

Compute the vertical range that the vertical scrollbar represents.


* Extend : 한 화면에 보여지는 View 의 크기(width || height) 

  - 아래 이미지에서 주황색 영역

* Offset : Scroll된 거리 -> -1을 곱하면 해당 뷰의 위치(x || y, top || left) 가 된다.

   --> staggered  grid layout 일 경우 값이 튀는(?) 경우들이 발생한다.

   --> 리스트가 scroll 될 때마다 child 의 위치가 변경되는 경우들이 발생하기 때문에 range 도 바뀌고 offset 들이 바뀌는 경우 들이 있기 때문이다.

* Range : Scroll 가능한 View 의 전체 크기 -> RecyclerView 의 크기( width || height )

   --> staggered grid layout 일 경우 스크롤링 하면 상황에 따라 계속 변경 됨


** 화면을 끝으로 이동하였을 때 offset + extend = range 가 된다.




- 참고 이미지 : HorizontalScrollView 에서의 각 수치들 설명 이미지 (http://android.keicode.com/basics/ui-custom-horizontalscrollview.php)

- 파란색 : 스크롤 가능한 View 전체

- 주황색 : 눈에 보여지는 View 의 영역

HorizontalScrollView



출처: http://ymson.tistory.com/entry/RecyclerView-의-Scroll-정보-얻기 [YeonMee's Tistory]

http://www.fontsaddict.com/

'기타' 카테고리의 다른 글

유니코드 변환  (0) 2020.08.05
쿼리 정리 사이트  (0) 2018.01.31
codebeautify  (0) 2017.12.02
맥 터미널 개발환경 구축하기  (0) 2017.12.02
나인패치 이미지 사이트  (0) 2017.12.02

+ Recent posts