Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.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 Coordinatorlayout_Bringtofront - Fatal编程技术网

Android 将自定义视图的前面置于协调器布局内

Android 将自定义视图的前面置于协调器布局内,android,android-coordinatorlayout,bringtofront,Android,Android Coordinatorlayout,Bringtofront,其实已经有类似的问题了 然而,并没有任何建议能帮助我使bringToFront在协调布局中发挥作用 下面是布局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.

其实已经有类似的问题了

然而,并没有任何建议能帮助我使bringToFront在协调布局中发挥作用

下面是布局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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include layout="@layout/toolbar"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"/>

        <android.support.v4.widget.DrawerLayout
            android:id="@+id/drawer_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:id="@+id/main_content_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

            <fragment
                android:id="@+id/navigation_drawer_container"
                android:name="..."
                android:layout_width="@dimen/navigation_drawer_width"
                android:layout_height="match_parent"
                android:layout_gravity="start"/>

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

    </LinearLayout>


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/..."
        android:clickable="true"
        android:layout_gravity="bottom|end"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="60dp"
        app:borderWidth="0dp"/>

    <CustomView
        android:id="@+id/customview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:orientation="vertical"
        android:visibility="gone"
        app:layout_behavior="..."/>

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

最后也

((View)mCustomView.getParent()).requestLayout();
但是没有成功。按钮仍在顶部

我错过什么了吗

也许还有其他的方法可以将自定义视图放在前面,或者将按钮放在自定义视图下

我还尝试向按钮添加一个行为,但由于它的可见性不仅取决于自定义视图,所以我放弃了这种方法


感谢您提前提供的帮助。

我终于找到了一个解决方法-如果我在AppBar上设置
setEnabled(false)
,它会转到后台,我可以在上面绘制其他东西,而不管API级别如何。

我也遇到了同样的问题,您最后解决了吗?@davidva nope。只是放弃了。但是,如果您不使用最新的android支持库,您是否尝试过升级android支持库?我通过translationZ属性解决了这个问题,该属性在API 21+上运行良好。稍后我们将讨论兼容性。我们正在使用最新的支持库。@DavidVávra我们不能使用它,我们需要支持API 14+
mCustomView.requestLayout();
mCustomView.invalidate();
((View)mCustomView.getParent()).requestLayout();