Android应用程序的后台问题

问题描述 投票:0回答:1

我正在使用 Android Studio 实现一个应用程序,并且创建了一个 Activity 来选择背景。如果我使用我已经实现的导航按钮,一切都会正常,但是如果我在BackgroundActivity中按下系统后退箭头,图像就会变小并且不会覆盖整个屏幕(如下所示)。我尝试在 onResume() 函数中重置背景,然后 invcalidate 但它不起作用。 我把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

android android-studio imageview
1个回答
0
投票

我怀疑你没有返回MainActivity,你现在处于选择bg antivity。

© www.soinside.com 2019 - 2024. All rights reserved.