3

我想達到的目標:摺疊式工具與tablayout

enter image description here

這個UI設計屬於Audio Beats

,在這裏我有什麼

enter image description here

。問題是當摺疊工具欄被展開時,tablayout在recyclerView後面。而且我無法刪除標題「Musico」或將它設置爲頂部爲粘性。

我的XML是

<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:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="200dp" 
    android:fitsSystemWindows="true" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     > 

     <ImageView 
      android:id="@+id/backdrop" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      android:src="@drawable/hp" 
      app:layout_collapseMode="parallax" 
      /> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:layout_collapseMode="pin" 
      android:layout_width="match_parent" 
      android:layout_height="90dp" 
      app:popupTheme="@style/AppTheme.PopupOverlay" > 

     </android.support.v7.widget.Toolbar> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      app:tabGravity="center" 
      android:layout_gravity="bottom" 
      app:tabMode="scrollable" /> 
    </android.support.design.widget.CollapsingToolbarLayout> 

</android.support.design.widget.AppBarLayout> 
<include layout="@layout/content_main"/> 
</android.support.design.widget.CoordinatorLayout> 

和content_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_main" 
app:behavior_overlapTop="30dp" 
> 

<android.support.v4.view.ViewPager 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/view_pager" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp"></android.support.v4.view.ViewPager> 
</RelativeLayout> 

請幫助。

回答

-2

只需給Tab佈局設置30dp的頁邊距並在必要時增加appbar佈局的大小。

+0

不起作用。視圖完全摺疊時,邊距保持不變。 –

+0

我可以知道如果您將TabLayout放在content_main.xml中,並在透視背景上方放置查看傳呼機。這個問題會解決嗎? – Nivedh

+0

Y ..我也嘗試過,但輸出結果與我在第一個gif中提到的相當,但不一樣。總的來說,這不是解決方案。 –

0

移動的TextView(MUsico)裏面的工具欄,並提供工具欄自定義佈局(它仍將上行頂部)

佈局是不正確的 參見:CollaspingLayoutwithviewpager

+0

首先,Musico不是textview.I不知道它是工具欄或colapsingToolbarLayout的標題。不過,我沒有爲其中的任何一個設置標題。這是應用程序名稱。其次,我已經訪問過這個鏈接,它有簡單的帶有摺疊工具欄的Tablayout。但是我想像我在第一個gif中展示的那樣定製視圖。 –