Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible CollapsingToolbarLayout height in SmoothViewPagerParallaxExitUntilCollapsedActivity #202

Open
dan-huang opened this issue Jun 19, 2017 · 8 comments

Comments

@dan-huang
Copy link

dan-huang commented Jun 19, 2017

Using the demo SmoothViewPagerParallaxExitUntilCollapsedActivity, I want to set CollapsingToolbarLayout height to: wrap_content. And add a textView with flexible height. Here I set the height to 100dp.

But there is a 156dp gap between TabLayout And RecycleView in ViewPager. How to avoid the gap or overlap when CollapsingToolbarLayout is not 256dp height?

<?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.v4.view.ViewPager
    android:id="@+id/view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

  <me.henrytao.smoothappbarlayout.SmoothAppBarLayout
    android:id="@+id/smooth_app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="@dimen/mdSecondaryActionBarSize">

    <android.support.design.widget.CollapsingToolbarLayout
      android:id="@+id/collapsing_toolbar_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:layout_scrollFlags="scroll|exitUntilCollapsed">

      <TextView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:text="@string/text_long"/>

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

    <android.support.design.widget.TabLayout
      android:id="@+id/tab_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" />
  </me.henrytao.smoothappbarlayout.SmoothAppBarLayout>
</android.support.design.widget.CoordinatorLayout>

wechatimg7

@henrytao-me
Copy link
Owner

Hi @dan-huang,

Please try to set @dimen/mdSecondaryActionBarSize to 100dp. I hope it helps.

Cheers,
Henry

@dan-huang
Copy link
Author

Hi @henrytao-me ,

Tried but the gap is still there..

@henrytao-me
Copy link
Owner

Hi @dan-huang,

I see what you mean. flexible height won't work. With SmoothAppBarLayout, you have to know height a head of time in order to maintain proper padding in scroll view. It's a trade off comparing to AppBarLayout. Sorry about not being helpful in this scenario.

Cheers,
Henry

@dan-huang
Copy link
Author

dan-huang commented Jun 20, 2017

Thanks anyway, @henrytao-me.
Is it possible to try it out myself base on smooth-app-bar-layout?

@henrytao-me
Copy link
Owner

Hi @dan-huang

I don't get what you mean Is it possible to try it out myself base on smooth-app-bar-layout??
I heard around that there is a fixed for flinging issue of AppBarLayout in upcoming release. I am still waiting for it. That's why I postpone to improve SmoothAppBarLayout.

@dan-huang
Copy link
Author

Hi @henrytao-me

I mean, When SmoothAppBarLayout height changed, each scrollView in ViewPager change it's padding accordingly.

Looking forward to the upcoming release.

@henrytao-me
Copy link
Owner

Technically, it's possible. However, it requires a lot of works in java code. Maybe you need to have some sort of event bus to synchronize height or some static variables or some custom callbacks.

@dan-huang
Copy link
Author

Thanks a lot.~ I'll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants