NestedScrollView의 ViewPager
접히는 헤더 (수직 스크롤) 위에 일종의 ViewPager (수평 스크롤) 인 Google 뉴스 스탠드와 같은 인터페이스를 만들어야합니다. 내 요구 사항 중 하나는 Google IO 2015에 제시된 새로운 디자인 지원 라이브러리를 사용하는 것입니다. ( http://android-developers.blogspot.ca/2015/05/android-design-support-library.html )
Chris Banes ( https://github.com/chrisbanes/cheesesquare )가 만든 샘플을 기반으로 축소 동작을 수행 할 수 있지만 기본 LinearLayout (가로 스크롤 없음)을 사용하는 지점에 도달했습니다.
LinearLayout을 ViewPager로 바꾸려고했는데 빈 화면이 생겼습니다. 나는 너비, 무게 및 모든 종류의 뷰 그룹을 가지고 놀았지만 .. 여전히 빈 화면입니다. ViewPager와 NestedScrollView가 서로를 좋아하지 않는 것 같습니다.
HorizontalScrollView를 사용하여 해결 방법을 시도했습니다. 작동하지만 PagerTitleStrip 기능의 이점과 단일 패널에 대한 초점을 잃어 버렸습니다 (두 패널 사이에서 가로로 중지 할 수 있음).
이제 더 이상 아이디어가 없습니다. 누군가 나를 해결책으로 이끌 수 있다면 ...
감사
다음은 내 최신 레이아웃 파일입니다.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
layout="@layout/part_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/activity_main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/activity_main_nestedscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="@+id/activity_main_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFA0"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
나는이 문제를 만난다. setFillViewport (true)
<android.support.v4.widget.NestedScrollView
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:id="@+id/nest_scrollview"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="mio.kon.yyb.nestedscrollviewbug.ScrollingActivity"
tools:showIn="@layout/activity_scrolling">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
활동 중
NestedScrollView scrollView = (NestedScrollView) findViewById (R.id.nest_scrollview);
scrollView.setFillViewport (true);
좋아요, 저는 ViewPager
및 NestedScrollView
. 내가 직면 한 문제는 높이 ViewPager
와 ListView
. 그래서 나는에 약간 수정했다 ListView
및 ViewPager's
높이 측정합니다.
누군가 코드를 살펴보고 싶다면 여기 링크가 있습니다 : https://github.com/TheLittleNaruto/SupportDesignExample/
산출:
추가 android:fillViewport="true"
귀하에 NestedScrollView
. 기간.
같은 문제가있었습니다.
ViewPager 주위 에 NestedScrollView를 배치하면 작동하지 않습니다.
그래도 작동하는 것은 NestedScrollView를 ViewPager 내부에서로드하는 조각의 레이아웃 안에 넣는 것 입니다.
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/fragment_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:orientation="vertical">
...Content...
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
NestedScrollView 내부에 ViewPager를 배치하는 대신 다른 방법으로 수행하십시오.
본질적으로 Fragment의 레이아웃 인 ViewPager 내의 자식 뷰에 NestedScrollView를 배치합니다. 또한 Fragment의 목록 레이아웃이 매우 간단한 경우 NestedScrollView를 사용할 필요가 없을 가능성이 매우 높습니다.
예제 레이아웃
활동의 레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/app_bar_height"
android:scaleType="centerCrop"
android:src="@drawable/my_bg"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.8"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.design.widget.TabLayout
android:id="@+id/content_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
TabLayout이 필요하지 않은 경우 LinearLayout을 버리고 ViewPager를 독립형으로 만들 수 있습니다. 그러나 app:layout_behavior="@string/appbar_scrolling_view_behavior"
ViewPager 속성에서 사용해야 합니다.
간단한 조각의 레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
복잡한 조각의 레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
예제 앱 : CollapsingToolbarPoc
이렇게 시도 할 수 있습니다. viewpager는 잘 작동하지만 viewpager의 높이는 고정되어 있습니다.
나는 여전히 더 나은 해결책을 찾고 있습니다. 그래서 어떤 점이 더 잘할 수 있는지 알려주십시오.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="800dp"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
나는 같은 문제가 있었고 몇 가지 변경 사항으로 수정했습니다. ViewPager
내에서 작동하지 않습니다 NestedScrollView
. 간단히 ViewPager
귀하의 CoordinatorLayout
. 그런 다음 각 ViewPager의 Fragment에 대한 콘텐츠를 NestedScrollView
. 그게 다야.
시차 효과를 얻기 위해 NestedScrollView를 사용할 필요가 없습니다. 다음과 같이 시도하십시오.
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_tab_layout"
android:fillViewport="false"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/my_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
주 레이아웃에서 NestedScrollView 를 제거 하고 ViewPager 에서로드해야하는 모든 Fragment 레이아웃에 부모 로 삽입 하여이 문제를 해결했습니다.
아래에 NestedScrollView가있는 앱 도구 모음이있는 레이아웃이 있었고 중첩 된 도구 모음 내부에는 LinearLayout이 있었고 LinearLayout 아래에는 뷰 페이저가있었습니다. 아이디어는 NestedScrollView 내부의 LinearLayout이 수정되었습니다.보기 페이저의보기 사이에서 왼쪽 / 오른쪽으로 슬라이드 할 수 있지만이 콘텐츠는 적어도 수평으로 이동하지 않습니다 . 중첩 된 스크롤보기로 인해 모든 콘텐츠를 세로로 스크롤 할 수 있어야합니다. 그게 아이디어였습니다. 그래서 중첩 된 NestedScrollView 높이를 match_parent로 설정하고 뷰포트를 채운 다음 모든 자식 레이아웃 / ViewPager를 wrap_content로 설정했습니다.
내 머릿속에서 옳았다. 그러나 작동하지 않았습니다. ViewPager를 사용하면 뷰 페이저 페이지 콘텐츠가 현재 화면의 맨 아래로 밀려 났는지 여부에 관계없이 왼쪽 / 오른쪽으로 이동할 수 있지만 수직 스크롤은 없습니다. 기본적으로 ViewPager가 다양한 페이지에서 wrap_content를 존중하지 않기 때문입니다.
ViewPager를 서브 클래 싱하여 현재 선택된 항목에 따라 높이를 변경하여 layout_height = "wrap_content"처럼 동작하도록 강제하여이 문제를 해결했습니다.
public class ContentWrappingViewPager extends ViewPager {
public ContentWrappingViewPager(Context context) {
super(context);
}
public ContentWrappingViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
if (getChildCount() > getCurrentItem()) {
View child = getChildAt(getCurrentItem());
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if(h > height) height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
솔루션은 이 답변 에서 영감을 받았습니다 . 나를 위해 일했습니다!
문제를 해결하려면 아래 맞춤 수업을 사용하세요. pagechangelistener에서 onRefresh () 메서드를 호출하는 것을 잊지 마십시오.
public class ContentWrappingViewPager extends ViewPager
{
private int width = 0;
public ContentWrappingViewPager(Context context) {
super(context);
}
public ContentWrappingViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
int height = 0;
width = widthMeasureSpec;
if (getChildCount() > getCurrentItem()) {
View child = getChildAt(getCurrentItem());
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if(h > height) height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public void onRefresh()
{
try {
int height = 0;
if (getChildCount() > getCurrentItem()) {
View child = getChildAt(getCurrentItem());
child.measure(width, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if(h > height) height = h;
}
int heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
ViewGroup.LayoutParams layoutParams = this.getLayoutParams();
layoutParams.height = heightMeasureSpec;
this.setLayoutParams(layoutParams);
} catch (Exception e) {
e.printStackTrace();
}
}
}
다음은 뷰 페이저의 적절한 높이를 보장해야합니다. 조각은 뷰 페이저에서 제공하는 첫 번째 조각입니다.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<fragment
class="com.mydomain.MyViewPagerFragment"
android:id="@+id/myFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
비슷한 문제가 발생했습니다 (하지만 CollapsingToolbarLayout
, 내에서 단순한 Toolbar
+ ). 내에서 의 내용을 아래로 스크롤 할 때 툴바가 보이지 않게 스크롤하기를 원 했습니다 .TabLayout
AppBarLayout
ViewPager
NestedScrollView
내 레이아웃은 다음과 같습니다.
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_tab_layout"
android:fillViewport="false"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="@+id/my_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
이 레이아웃은 의도 한대로 작동하지 않았지만 단순히를 제거 NestedScrollView
하고 LinearLayout
대신 a 를 사용하여 해결했습니다 . Android 지원 라이브러리 v23.1.0에서 즉시 작동했습니다. 레이아웃이 완성 된 방법은 다음과 같습니다.
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_tab_layout"
android:fillViewport="false"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:orientation="vertical"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="@+id/my_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
추신 : 이것은 실제로 내 프로젝트에서 두 개의 레이아웃 파일이었습니다. 여기에 복사하여 붙여 넣은 다음 단일 파일처럼 구성하려고했습니다. 복사해서 붙여 넣다가 엉망이 됐다면 미안하지만 그럴 경우 알려 주시면 고칠 수 있습니다.
이 줄을 NestedScrollView에 넣으십시오.
android:fillViewport="true"
저도 같은 소원, 둥지 a를 가지고 ViewPager
, 안쪽을 NestedScrollView
. 그러나 그것은 나에게도 효과가 없습니다. 제 경우 ViewPager
에는는 내부에 Fragment
있으므로 서랍과의 상호 작용에 따라 콘텐츠를 전환 할 수 있습니다. 물론 AppBar, 축소 등 지원 라이브러리의 모든 새로운 기능이 작동해야합니다.
사용자가 페이저에서 페이지를 세로로 스크롤하면 다른 페이지도 동일하게 스크롤하여 페이저 자체가 스크롤 한 전체적인 인상을 사용자에게 제공합니다.
내가 한 일은 더 이상 ViewPager
내부에 포함하지 않고 NestedScrollView
대신 포함 된 조각의 내용을 NestedScrollView
.
그런 다음 하나의 조각에 스크롤이있는 경우 컨테이너에 새 스크롤 위치를 알려주고이를 저장합니다.
마지막으로, 호출기에서 감지 된 왼쪽 또는 오른쪽으로 스 와이프하면 ( addOnPageChangeListener
드래그 상태 찾기 사용 ) 대상이 스크롤해야하는 위치 (컨테이너 지식에 따라)가 내가 가져온 조각에서 정렬되도록 왼쪽 또는 오른쪽 조각에 알립니다.
한 가지 작업 솔루션을 알고 있습니다. CoordinatorLayout과 함께 Activity를 사용하고 컨테이너 인 FrameLayout을 사용합니다. 그때. 조각 관리자를 사용하여 조각을 컨테이너에 넣습니다. 예를 들어 내 코드 :
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/colorPrimary"
android:gravity="center">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</FrameLayout>
그리고 조각 :
<LinearLayout 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:orientation="vertical"
tools:context="com.improvemdia.inmyroom.MainFragment">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
그런 다음 FragmentManager를 사용하십시오.
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, new MainFragment())
.commit();
몇 시간 동안 위의 모든 제안을 시도한 후 마침내 작동했습니다. 핵심은 NestedScrollView
내부 PageViewer
에 넣고 두 뷰 모두layout_behavior
에 '@string/appbar_scrolling_view_behavior'
대해 설정 하는 것 입니다 . 최종 레이아웃은 다음과 같습니다.
<CoordinatorLayout>
<ViewPager app:layout_behavior="@string/appbar_scrolling_view_behavior">
<NestedScrollView fillViewport="true" app:layout_behavior="@string/appbar_scrolling_view_behavior">
<Content>...</Content>
</NestedScrollView>
</ViewPager>
<AppBarLayout>...</AppBarLayout>
</CoordinatorLayout>
xml 에서 NestedScrollView 를 제거 하고이 코드를 클래스에 추가했습니다.
yourGridView.setNestedScrollingEnabled(true);
실제로 NestedScrollView는 CoordinatorLayout에서 CollapsingToolbarLayout의 직접적인 형제 일 필요가 없습니다. 나는 정말 기묘한 것을 성취했습니다. appbar_scrolling_view_behavior는 2 개의 중첩 조각에서 작동합니다.
내 활동 레이아웃 :
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<include
layout="@layout/toolbar"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
"container"frameLayout에서이 조각을 부풀 렸습니다.
<android.support.constraint.ConstraintLayout>
... some content ...
<android.support.v4.view.ViewPager/>
...
</android.support.constraint.ConstraintLayout>
그리고 그 ViewPager 내부의 조각은 다음과 같습니다.
<RelativeLayout>
<android.support.v7.widget.RecyclerView/>
....
</RelativeLayout>
NestedScrollView가 CoordinatorLayout 자식 계층 구조와 스크롤 동작에서 너무 깊을 수 있다는 사실은 저를 놀라게했습니다.
참고 URL : https://stackoverflow.com/questions/30580954/viewpager-in-a-nestedscrollview
'developer tip' 카테고리의 다른 글
표준 10 자리 전화 번호와 일치하는 정규식 (0) | 2020.08.21 |
---|---|
Guzzle 예외 처리 및 HTTP 본문 가져 오기 (0) | 2020.08.21 |
jquery.validate.unobtrusive가 동적 주입 요소와 함께 작동하지 않습니다. (0) | 2020.08.21 |
원격 컴퓨터의 디스크 용량과 여유 공간을 얻는 방법 (0) | 2020.08.21 |
Intellij IDEA가 충돌하여 이제 오류가 발생합니다. (0) | 2020.08.21 |