[英]BringToFront of the custom view inside a coordinator layout
實際上已經存在類似的問題BringToFront在協調器布局中不起作用
然而,沒有任何建議幫助我使bringToFront在Coordinatorlayout中工作。
這是layout-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>
自定義視圖繼承自FrameLayout。 它可以改變它的高度。
為了首先將自定義視圖置於最前面,我嘗試添加:
mCustomView.bringToFront();
然后
mCustomView.requestLayout();
mCustomView.invalidate();
最后也是
((View)mCustomView.getParent()).requestLayout();
但沒有成功。 按鈕仍位於頂部。
我錯過了什么嗎?
也許有其他可能將自定義視圖置於前面或將按鈕置於自定義視圖下?
我還嘗試向按鈕添加一個行為,但由於它的可見性不僅取決於自定義視圖,而且還拋棄了這種方法。
感謝您提前提供的任何幫助。
我終於找到了一個解決方法 - 如果我在AppBar上設置setEnabled(false)
,它會轉到后台,無論API級別如何,我都可以在其上繪制其他內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.