gpt4 book ai didi

Android - 状态栏阻止全屏

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

我的应用在启动时可以全屏正确运行。然而,在最小化并返回到应用程序后,状态栏弹出并将我的 View 向下推了一点。如何防止状态栏移动我的 View ?

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.example.draw"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.example.draw.DrawView
android:id="@+id/draw"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:fitsSystemWindows="false"
/>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
android:layout_gravity="bottom"
/>

这是我 Activity 的 onCreate 的一部分:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

我在 list 中也有全屏主题:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

谢谢

最佳答案

您可以通过以下方式解决此问题:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

(在 onCreate 中执行此操作)...请注意,这会破坏软键盘 (IME) - 因为编辑文本无法再滑入键盘上方的 View 中。 该标志会阻止窗口完全移动....

如果您需要在修复状态错误的同时编辑文本,您可以这样做

someEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} else {
hideKeyboard();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}
});

关于Android - 状态栏阻止全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3074398/

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