簡體   English   中英

如何在標簽中添加浮動操作按鈕?

[英]How to add floating action button in tabs?

我有一個選項卡式布局。 所以我有七個片段。 我想在所有片段上添加一個浮動操作按鈕。 因此,在所有片段上應該只在浮動按鈕上。

我試圖將fab添加到主要活動布局中,但是它被片段隱藏而不顯示出來。 我該如何實現?

我在此和滑動標簽布局中使用了滑動標簽條。

主要活動布局:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" tools:context="com.adgatemedia.offerwallsdk.fragments.MainFragment">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <utils.SlidingTabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="2dp"
            android:background="@color/colorPrimary"
            android:layout_alignParentTop="true" />

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

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_gravity="bottom|end">

            <include layout="@layout/myfab"/>
        </LinearLayout>

    </RelativeLayout>
</FrameLayout>

適配器:

    public class TabsPagerAdapter extends FragmentPagerAdapter {

    CharSequence Titles[];
    int NumbOfTabs;
    public TabsPagerAdapter(FragmentManager fm,CharSequence mTitles[], int mNumbOfTabsumb) {
        super(fm);
        this.Titles = mTitles;
        this.NumbOfTabs = mNumbOfTabsumb;
    }

    @Override
    public Fragment getItem(int index) {

        switch (index) {
            case 0:
                return new Mon();
            case 1:
                return new Tue();
            case 2:
                return new Wed();
            case 3:
                return new Thu();
            case 4:
                return new Fri();
            case 5:
                return new Sat();
            case 6:
                return new Sun();

        }
        return null;
    }
    @Override
    public CharSequence getPageTitle(int position) {
        return Titles[position];
    }
    @Override
    public int getCount() {
        return NumbOfTabs;
    }
}

謝謝..

實現此目的的最佳方法是在巡回活動中添加浮動動作按鈕。 您能否發布活動,以便我們跟蹤您的代碼並查看您的片段為何與操作按鈕重疊?

暫無
暫無

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

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