[英]How to make view on top of another view in CoordinatorLayout?
[英]Unnecessary view on top of CoordinatorLayout
查看層次結構
<LinearLayout>
<Toolbar>..
</Toolbar>
<FrameLayout>
<CoordinatorLayout>..
<FrameLayout>
</FrameLayout>
</CoordinatorLayout>
</FrameLayout>
</LinearLayout>
想要擺脫那條深藍色的條紋。 不知道為什么 Co-ordinatorLayout 將這個視圖附加到頂部。 我嘗試用 LinearLayout 替換它,這導致了預期的結果。 無法弄清楚為什么和什么視圖顯示為藍色暗條。
toolbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
app:title="DISCOVER"
app:titleTextAppearance="@style/TextAppearance.MyApp.Widget.ActionBar.Title" />
<View
style="@style/Divider"
android:background="@color/grey_light" />
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
</FrameLayout>
</LinearLayout>
活動_main.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"
android:fitsSystemWindows="true"
tools:context="com.discover.MainActivity">
<FrameLayout 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:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.discover.MainActivity"
tools:showIn="@layout/activity_main"
android:layout_margin="0dp"
android:background="#11a2cb"></FrameLayout>
</android.support.design.widget.CoordinatorLayout>
基本活動.java
@Override
public void setContentView(int layoutResID) {
super.setContentView(R.layout.toolbar_layout);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mContentlayout = (FrameLayout) findViewById(R.id.content);
setSupportActionBar(mToolbar);
getLayoutInflater().inflate(layoutResID, mContentlayout);
}
在 MainActivity 我使用setContentView(R.layout.activity_main)
解決方案:
將android:fitsSystemWindows="true"
到根布局即 LinearLayout 在我的情況下就像一個魅力。
原因:
我仍然想知道正在展示什么神秘的景色。 如果有人可以指出,請回復以更清楚地了解問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.