工具栏上方的可绘制面板

时间:2017-04-06 13:31:32

标签: android android-layout android-toolbar android-coordinatorlayout

我的活动包含 - ToolbarTabsViewPagerFloatingActionButtonDraggablePanel

初始化我的可拖动面板时,它会显示在ToolbarFloatingButtonTabs下方。设置DraggablePanel.bringToFront()只会使其高于ViewPager。初始化后如何将DraggablePanel置于所有内容之上?

  

布局文件:

<?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"
    xmlns:draggable_panel="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="in.brewtv.activities.HomeActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="false"
            app:tabGravity="fill"
            app:tabMode="fixed" />


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


    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@drawable/change_mood" />

    <!-- DraggablePanel -->

    <com.github.pedrovgs.DraggablePanel
        android:id="@+id/draggable_panel"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        draggable_panel:x_scale_factor="2.3"
        draggable_panel:y_scale_factor="2.3"
        draggable_panel:top_fragment_height="200dp"
        draggable_panel:top_fragment_margin_right="10dp"
        draggable_panel:top_fragment_margin_bottom="10dp"
        draggable_panel:enable_horizontal_alpha_effect="true"/>


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

截屏:

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试将提升设置为 FAB 的值高于 DraggablePanel

 <com.github.pedrovgs.DraggablePanel
    android:id="@+id/draggable_panel"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:elevation="10dp"
    draggable_panel:x_scale_factor="2.3"
    draggable_panel:y_scale_factor="2.3"
    draggable_panel:top_fragment_height="200dp"
    draggable_panel:top_fragment_margin_right="10dp"
    draggable_panel:top_fragment_margin_bottom="10dp"
    draggable_panel:enable_horizontal_alpha_effect="true"/>