gpt4 book ai didi

android - CoordinatorLayout 子项不是全屏

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:05:05 24 4
gpt4 key购买 nike

我有一个全屏显示的 Activity。这适用于我尝试过的许多布局,但当 CoordinatorLayout 是根 ViewGroup 时除外。 CoordinatorLayout 本身的宽度和高度都设置为 match_parent 并且它应该占据整个屏幕。但是应该与 CoordinatorLayout 具有相同大小的 subview 被放置,就好像导航栏仍然可见一样。

Illustration of the problem

有没有办法通过 CoordinatorLayout 调整 subview 的大小?显然 fitSystemWindows 不会改变任何东西,因为这可能是由 CoordinatorLayout 实现引起的,其他 ViewGroups 工作正常。我尝试创建自定义 Behavior 类,但没有成功。

我使用此代码使我的 Activity 全屏显示:

@Override
protected void onResume() {
super.onResume();
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
}

这是一个用于生成图像的简单布局:

<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:fitsSystemWindows="true"
android:background="#F00">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/background_sky_light" />

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

最佳答案

如果您正在使用 coodinatorlayout,请将 android:fitsSystemWindows 更改为 falseandroid:fitsSystemWindows="false"

关于android - CoordinatorLayout 子项不是全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31806112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com