henrytao-me / smooth-app-bar-layout

Smooth version of Google Support Design AppBarLayout
Apache License 2.0
1.77k stars 240 forks source link

Flexible CollapsingToolbarLayout height in SmoothViewPagerParallaxExitUntilCollapsedActivity #202

Open dan-huang opened 7 years ago

dan-huang commented 7 years ago

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 commented 7 years ago

Hi @dan-huang,

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

Cheers, Henry

dan-huang commented 7 years ago

Hi @henrytao-me ,

Tried but the gap is still there..

henrytao-me commented 7 years ago

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 commented 7 years ago

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

henrytao-me commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

Thanks a lot.~ I'll try.