2015-04-15 76 views
1

使滾動動畫背景沒有填滿,我做錯了什麼?android hide/show工具欄沒有填充空格底部

我使用 - DrawerLayout - V7工具欄 - 尋呼機 - SwipeRefreshLayout - RecyclerView

活動

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar" /> 

    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"></FrameLayout> 

片段尋呼機容器

<RelativeLayout 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"> 

<com.squidit.squid.ui.widget.SlidingTabLayout 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:elevation="2dp" 
    android:background="@color/primaryColor"/> 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

片段內容

<android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/missionSwipeRefresh" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"   
    /> 

滾動隱藏

private void hideViews() { 
    mToolbar.animate().translationY(-mToolbar.getHeight()).setInterpolator(new DecelerateInterpolator(2)); 
    container.animate().translationY(-mToolbar.getHeight()).setInterpolator(new DecelerateInterpolator(2)).start();   
} 

問題:

容器上升到頂部,但通過將其預先在底部所佔據的空間是無填充

Ilustration:

https://drive.google.com/open?id=0B-Vxv0Qpz2dqcWp5eDVRbmd3czQ&authuser=0

+0

您的插圖無法正常工作,需要權限。你爲什麼將整個容器與工具欄一起移動? –

+0

@MichałZ。請再次檢查鏈接。我發現我的問題是與抽屜佈局有關,但尚未決定。 –

回答

-1

我幾乎同樣的問題。 隱藏工具欄和狀態欄後,我的佈局看起來像 http://i62.tinypic.com/qowvgi.png

編輯: 您可能注意到翻譯與移動視圖不同。 要在ValueAnimator內部的動畫設置LayoutParams.height上調整佈局的大小。

mToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar); 
    toolbarHeight = mToolbar.getHeight(); 

最後

ValueAnimator anim = ValueAnimator.ofInt(toolbarHeight, 0); 
    anim.setDuration(1000); 
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 
     @Override 
     public void onAnimationUpdate(ValueAnimator animation) { 
      Integer value = (Integer) animation.getAnimatedValue(); 
      mToolbar.getLayoutParams().height = value.intValue(); 
      mToolbar.requestLayout(); 

     } 
    }); 
    anim.start(); 

上面的代碼隱藏影響主要佈局以擴大自身的工具欄。從THAT QUESTION給出的想法。

此外,請確保您正在使用fitsSystemWindows在即將調整大小的佈局中。

android:fitsSystemWindows = "true" 
+0

請不要使用解答發表評論。 –

+0

@ murt - 正確的方法是獲得更多聲望(而不是混淆其他問題的水域)或提出自己的問題。 –

+0

感謝您的諮詢! – murt