滚动屏幕截图包含在AppBarLayout

时间:2015-08-21 13:52:35

标签: android material-design android-design-library androiddesignsupport

我正在测试新的支持设计库,我遇到了以下问题。

当滚动到顶部时,toolbarimageView视图会按原样崩溃,但我也想在屏幕外滚动CustomViewPager。

我为CustomViewPager编写了一个CustomBehavior,但它似乎没有被调用,可能是因为它在appbar中。我不能把它放在AppBarLayout之外,否则会被截断。 我设法隐藏了CustomViewPager,但是当它发生时,视图跳跃并且看起来不太好,因此我想在屏幕外滚动它。

有什么建议吗?     

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">
    <com.views.NetworkImageViewExt
        android:id="@+id/imageViewPostDebate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/holding_image_post_dashboard"
        android:scaleType="centerCrop"
        app:layout_collapseMode="parallax"
        android:fitsSystemWindows="true"
        />

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_collapseMode="pin" />
        <ImageView
            android:id="@+id/imageViewVideoIcon"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:src="@drawable/play_video"
            android:layout_gravity="center"
            android:fitsSystemWindows="true"
            />
    </android.support.design.widget.CollapsingToolbarLayout>
    <com.views.CustomViewPager
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible"
        android:id="@+id/viewPager"
        android:fitsSystemWindows="true"
        app:layout_behavior="@string/viewpager_scrolling_view_behavior"
       />
</android.support.design.widget.AppBarLayout>

<com.views.FixedRecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/comments_recycle_view"
    android:background="@color/white"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    />

<android.support.design.widget.FloatingActionButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    app:layout_anchor="@id/post_coordinator_layout"
    android:id="@+id/add_comment"
    app:layout_anchorGravity="bottom|right|end"
    android:src="@drawable/share_icon_xxhdpi"
    android:layout_margin="@dimen/view_margin_10"
    android:clickable="true"/>

public class CustomViewPagerBehaviour extends CoordinatorLayout.Behavior<CustomViewPager> {

public CustomViewPagerBehaviour(Context context, AttributeSet attrs) {
    super();
}

@Override
public boolean layoutDependsOn(CoordinatorLayout parent, CustomViewPager child, View dependency) {
    return dependency instanceof FixedRecyclerView || dependency instanceof CollapsingToolbarLayout ||
            dependency instanceof AppBarLayout;
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, CustomViewPager child, View dependency) {
    if(translationY < -1000){
        child.setVisibility(View.GONE);
    }else
    {
        child.setVisibility(View.VISIBLE);
    }
    return true;
}

}

0 个答案:

没有答案