[英]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.