Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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
Android 将视图放在“表格布局”下方的“内部视图”页导航中_Android_Android Viewpager_Android Tablayout - Fatal编程技术网

Android 将视图放在“表格布局”下方的“内部视图”页导航中

Android 将视图放在“表格布局”下方的“内部视图”页导航中,android,android-viewpager,android-tablayout,Android,Android Viewpager,Android Tablayout,我正在寻找一种方法,将视图放在选项卡栏下方的查看页面。 我不希望它在每个片段中,因为每次我更改当前片段时,它都会滚动;我需要在没有动画的情况下修复该视图 这就是我现在将视图放在表格中的内容[code+img] 您的表格布局不能是ViewPager的子项 <LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools

我正在寻找一种方法,将
视图
放在
选项卡栏
下方的
查看页面
。 我不希望它在每个
片段中,因为每次我更改当前片段时,它都会滚动;我需要在没有动画的情况下修复该视图

这就是我现在将
视图
放在
表格中的内容
[code+img]


您的表格布局不能是ViewPager的子项

<LinearLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="?android:actionBarSize"
                style="@style/AppTabLayout"
                app:tabTextAppearance="@style/AppTabTextAppearance"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:tabMode="fixed"
                app:tabGravity="fill"/>
            <!--here put your view, the one you want to appear in all pages.-->
        </LinearLayout>
    </android.support.design.widget.AppBarLayout>
    <FrameLayout
        android:id="@+id/popup_holder"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:background="@android:color/white"/>
    </FrameLayout>
</LinearLayout>

您的表格布局不能是ViewPager的子项

<LinearLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="?android:actionBarSize"
                style="@style/AppTabLayout"
                app:tabTextAppearance="@style/AppTabTextAppearance"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:tabMode="fixed"
                app:tabGravity="fill"/>
            <!--here put your view, the one you want to appear in all pages.-->
        </LinearLayout>
    </android.support.design.widget.AppBarLayout>
    <FrameLayout
        android:id="@+id/popup_holder"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:background="@android:color/white"/>
    </FrameLayout>
</LinearLayout>

您可以使用默认的android选项卡,如下所示: 右键单击应用程序>新建>活动>选项卡式活动。 它会为你创造一切。 如果要更改背景色的颜色-下划线颜色或文本颜色。 您可以在XML或用户界面中执行此操作

TabLayout tabLayout = binding.tabs;
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.setTabTextColors(getResources().getColor(R.color.white), getResources().getColor(R.color.white));

您可以使用默认的android选项卡,如下所示: 右键单击应用程序>新建>活动>选项卡式活动。 它会为你创造一切。 如果要更改背景色的颜色-下划线颜色或文本颜色。 您可以在XML或用户界面中执行此操作

TabLayout tabLayout = binding.tabs;
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.setTabTextColors(getResources().getColor(R.color.white), getResources().getColor(R.color.white));

这管用!非常感谢,我一直误用它:这很有效!非常感谢,我一直误用它:D