我正在使用Android Studio实现一个应用程序,并创建了一个 Select 背景的活动.如果我使用我已经意识到的导航按钮,一切都很好,但如果我在后台活动中按下系统向后箭头,图像会变小,并且不会覆盖整个屏幕(如下所示).我try 在onResume()函数中重置背景,然后取消它,但没有起作用. 下面是onResume()函数的代码以及后台是如何实现的 希望问题清楚了

<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"
    tools:context=".MainActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/imgBg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:background="@drawable/background0" />

    <androidx.constraintlayout.widget.ConstraintLayout
...
    @Override
    protected void onResume() {
        super.onResume();

        //Gestione sfondo
        ImageView bg = findViewById(R.id.imgBg);
        bg.setBackground(MainActivity.bgs.getActive());
        bg.invalidate();
    }

When you first open it is like this

Then you select a new background and it opens this

But if you press the backarrow on the left of the system nav bar it happens this

推荐答案

我也有同样的问题,你用同样的抽屉来 Select BG和小RECT. 要解决此问题,请创建可绘制文件的副本或使用R.Drawable.bg直接获取资源

Android相关问答推荐

无法安装后重新编译android代码'

使用Retrofit2的API调用:我如何能够一直进行API调用,以更新数据而无需重新打开应用程序

如何禁用Android 34+版的TileService,但保留以前的版本?

NativeScript在`ns run android`上重复Kotlin类

如何使用Jetpack Compose实现此底表?

Kotlin Android VS Kotlin多平台

未解析的引用:视图模型

Android 12+BLE字节不同

AndroidX Media3 迁移指南

如何使用 Wea​​r OS 上的运行状况服务模拟位置?

相机2问题:设置AE区域、AF区域和AWB区域.

Jetpack Compose 中的用户在线指示器

在一个函数中组合相同的流 struct

如何在 Delphi 和 Android 上避免 Indy Socket Error #13 Access denied 异常?

前台服务通知需要几秒钟才能显示

如何对齐文本和图标可组合,以便即使在文本溢出后它们也能保持在一起?

在 Kotlin 客户端应用程序中发送 FCM 推送通知 - Firebase 云消息传递

在 jetpack compose 中使用 viewmodel 的最佳实践

如何在 Jetpack Compose 中填充矢量图像的背景?

将生成的 AAR 与 Composables 一起使用时未解决的参考