Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法仅在一个选项卡中显示浮动按钮-使用SlidingTableOut和android.support.design_Android_Android Fragments_Floating Action Button - Fatal编程技术网

无法仅在一个选项卡中显示浮动按钮-使用SlidingTableOut和android.support.design

无法仅在一个选项卡中显示浮动按钮-使用SlidingTableOut和android.support.design,android,android-fragments,floating-action-button,Android,Android Fragments,Floating Action Button,我是android应用程序开发新手,并实现了一个SlidingTableOut。我想在其中一个选项卡中显示浮动按钮,但无法执行此操作。我试着将我的按钮和我的主要活动都包含在我的标签片段中。在mainactivity中,当我切换选项卡时,按钮仍包含在第二个选项卡中。我尝试了floatingbutton.show()并隐藏在我的选项卡更改侦听器中,但没有任何用处。任何帮助都将不胜感激。My activity_main.xml <android.support.v4.widget.DrawerL

我是android应用程序开发新手,并实现了一个SlidingTableOut。我想在其中一个选项卡中显示浮动按钮,但无法执行此操作。我试着将我的按钮和我的主要活动都包含在我的标签片段中。在mainactivity中,当我切换选项卡时,按钮仍包含在第二个选项卡中。我尝试了floatingbutton.show()并隐藏在我的选项卡更改侦听器中,但没有任何用处。任何帮助都将不胜感激。My activity_main.xml

<android.support.v4.widget.DrawerLayout
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:id="@+id/drawerlayout" android:layout_height="match_parent"
android:layout_width="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.pegasus.tabstutorial.MainActivity">

    <include
        android:id="@+id/app_bar"
        layout="@layout/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.pegasus.tabstutorial.SlidingTabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primaryColor" />

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

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:src="@mipmap/ic_launcher"
        app:layout_anchor="@+id/appbarLayout"
        app:layout_anchorGravity="bottom|right|end"
        android:layout_marginBottom="37dp"
        android:layout_alignParentBottom="true"/>

   </RelativeLayout>

   <fragment
    android:layout_width="280dp"
    android:layout_height="wrap_content"
    tools:layout="@layout/fragment_navigation_drawer"
    android:id="@+id/navDrawer"
    android:layout_gravity="start"/>

    </android.support.v4.widget.DrawerLayout>` 

` 
还有我的主页_tab.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="You Are In Tab Home Tab"
    android:id="@+id/textView"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

 </RelativeLayout>

使用了上述解决方案,并且能够解决此问题。使用上述解决方案并能够解决此问题。