【问题标题】:How to add floating action button in tabs?如何在选项卡中添加浮动操作按钮?
【发布时间】:2016-02-11 12:02:20
【问题描述】:

我有一个选项卡式布局。所以我有七个片段。我想在所有片段上添加一个浮动操作按钮。所以在所有片段上应该只有浮动按钮。

我试图在主要活动布局中添加工厂,但它被片段隐藏了它不显示。我怎样才能做到这一点?

我在这个和滑动标签布局中使用了滑动标签条。

主要活动布局:

    <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;
    }
}

谢谢你..

【问题讨论】:

    标签: android android-fragments android-tabs floating-action-button pagerslidingtabstrip


    【解决方案1】:

    实现此目的的最佳方法是将浮动操作按钮添加到游览活动中。您能否发布您的活动,以便我们跟踪您的代码并查看为什么您的片段与您的操作按钮重叠?

    【讨论】:

      猜你喜欢
      • 2016-05-30
      • 2021-05-12
      • 2015-02-16
      • 2016-03-27
      • 2015-09-18
      • 1970-01-01
      • 1970-01-01
      • 2017-05-20
      • 1970-01-01
      相关资源
      最近更新 更多