当前位置: 首页 > 知识库问答 >
问题:

隐藏在操作栏选项卡后面的viewPager片段

公孙鸿才
2023-03-14

实际上,我正在尝试构建一个ListView/RecycerView。在滚动列表时,actionbar get hide,其中action bar是工具栏,但listview的某些部分隐藏在选项卡后面。在这里,我使用了AppBarLayout和工具栏,其中有app:layout_scrollflags=“scrollenterAlways”,在我的recylerview中有app:layout_behavior=“@string/appbar_scrolling_view_behavior”行为。我可以使用线性布局,但问题是对于工具栏的滑动,AppBarLayout必须是CoordinatorLayout的子级。

我的具有xml的活动

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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"
    tools:context="ameyo.genie.activity.HomeActivity">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="50dp">

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

    </FrameLayout>



        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
            app:theme="@style/Toolbar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/action_bars"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
           />
            <ameyo.genie.SlidingTabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:background="@color/colorPrimary"
                />

        </android.support.design.widget.AppBarLayout>



    <android.support.design.widget.FloatingActionButton
        android:id="@+id/home_fab_dial"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:clickable="true"
        android:src="@drawable/ic_dialpad_white"
        app:layout_anchor="@id/pager"
        app:layout_anchorGravity="bottom|center" />


</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recentcall_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />

</android.support.design.widget.CoordinatorLayout>

是我在使工具栏在滑动listview时做错了什么,还是有另一种方法不用使用任何第三个库就可以做到这一点。

共有1个答案

史俊德
2023-03-14

试试这个:

    <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
            app:theme="@style/Toolbar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/action_bars"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
           />
            <ameyo.genie.SlidingTabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:background="@color/colorPrimary"
                />
 <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="50dp">

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

    </FrameLayout>

        </android.support.design.widget.AppBarLayout>

当你把你的组件,排序他们的位置,每个组件将超过先例,如果没有空间!

 类似资料:
  • 我有一个活动有3个碎片(不是标签)。我有几个动作条项目,我想隐藏他们时,某个片段是存在的。我该怎么做呢?

  • 主要内容:ion-tabs,实例,ion-tab,$ionicTabsDelegateion-tabs ion-tabs 是有一组页面选项卡组成的选项卡栏。可以通过点击选项来切换页面。 对于 iOS,它会出现在屏幕的底部,Android会出现在屏幕的顶部(导航栏下面)。 用法 实例 <ion-tabs class="tabs-positive tabs-icon-only"> <ion-tab title="首页" icon-on="ion-ios-filing" icon-off

  • ion-tabs ion-tabs 是有一组页面选项卡组成的选项卡栏。可以通过点击选项来切换页面。 对于 iOS,它会出现在屏幕的底部,Android会出现在屏幕的顶部(导航栏下面)。 用法<ion-tabs class="tabs-positive tabs-icon-only"> <ion-tab title="首页" icon-on="ion-ios-filing" icon-off="io

  • 就我一直在寻找的情况而言,我没有为我的代码提出一个好的最终解决方案。我试图实现类似这样的布局: 动作栏 null

  • 问题内容: 我实现了带有ViewPager和TabsAdapter的ActionBarSherlock。它运作良好,但是现在我试图从另一个表中的“标签1”中加载的框架中“推送”。 该行为应类似于: 我的应用程序中有3个选项卡,启动时会看到第一个选项卡,其中有一个带有按钮的片段 按下第一个选项卡上的按钮,应替换第一个选项卡上的片段,并显示另一个片段 我试图实现这一点,但是在更换时有一个黑色的片段。

  • 我找到的唯一解决办法就是打电话给 在显示父片段之后。这会以某种方式触发视图被重新创建并出现在屏幕上。不幸的是,这有时会导致在旧的观察器上处理两次调用的寻呼机适配器时出现异常。 有没有更好的办法做到这一点?我想我要问的是: