回答

2

你可以在FrameLayout的幫助下做到。

<android.support.v7.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:id="@+id/card_view" 
android:layout_width="match_parent" 
android:layout_height="280dp" 
android:layout_gravity="center" 
app:cardElevation="8dp" 
card_view:cardCornerRadius="5dp"> 

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

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


     <SlidingTabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#2D73A9" 
      android:elevation="2dp" /> 

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

    </LinearLayout> 

    <FrameLayout 
     android:id="@+id/buttonPanel" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_gravity="top|end" 
     android:layout_marginEnd="0dp" 
     android:layout_marginRight="0dp"> 

     <Button 
      android:id="@+id/expand" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/img_chart_expand" 
      android:visibility="gone" /> 
    </FrameLayout> 

</FrameLayout> 
0

是否有意義添加旁邊TabLayout按鈕?管理起來要容易得多(只需要一個包含alignParentRight和tabLayout to_leftOf的按鈕),結果將是一樣的。

+0

是的我試過了,但滑動條的行爲發生變化,頁面無法順暢滑動! –

相關問題