簡體   English   中英

將浮動操作按鈕與選項卡一起使用

[英]Using Floating Action Button With Tabs

我正在使用帶有slidetablayout的浮動操作按鈕,但是當我在片段中使用fab時,每個選項卡都將擁有自己的fab,並且過渡效果很差,就像谷歌設計http://material-design.storage.googleapis.com/publish/ material_v_4 / material_ext_publish / 0B6Okdz75tqQsNVRkV3FZMktvMWc / components-buttons-fab-behavior_06_xhdpi_009.webm當我在viewpager中使用fab時,它會像在鏈接https://drive.google.com/file/d/view/0By6vpus

這是我的代碼activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<com.smooth.www.smooth.SlidingTabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="2dp"
    android:background="@color/ColorPrimary"/>

<android.support.v4.view.ViewPager
    android:id="@+id/pager"

    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_weight="1"
    />
</LinearLayout>

和我的其中一個標簽

<android.support.design.widget.CoordinatorLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#f0f0f0"
>
<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/tab_main_swipe_refresh_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
<android.support.v7.widget.RecyclerView
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/main_recycler"
    />
</android.support.v4.widget.SwipeRefreshLayout>



<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:fabSize="normal"
    android:id="@+id/main_fab"
    android:layout_gravity="bottom|right"
    android:layout_margin="16dp"
    android:transitionName="@string/fab_transition_name"
    android:src="@drawable/fab_image"
    app:layout_anchor="@id/main_recycler"
    app:layout_anchorGravity="bottom|right|end"
    />
</android.support.design.widget.CoordinatorLayout>

我要怎么做才能使過渡看起來不錯??

看起來您正在使用LinearLayout或其他東西,而不是RelativeLayout。 您可以發布代碼段嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM