есть код MainActivity на Kotlin:
package com.example.mfa2
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.graphics.Color
import com.example.mfa2.ui.theme.Mfa2Theme
import androidx.compose.material3.Text
import android.widget.ImageView
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val mainLayout = findViewById<ImageView>(R.id.main_layout)
mainLayout.setBackgroundResource(R.drawable.ks)
setContent {
Mfa2Theme {
Surface(
modifier = Modifier.fillMaxSize(),
) {
Greeting("ксюша")
}
}
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text(
text = "привет, $name!\nя эту штуку запрограммировал",
modifier = modifier,
textAlign = TextAlign.Center,
color = Color.Green
)
}
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
Mfa2Theme {
Greeting("ксюша")
}
}
вот что находится в activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:background="@drawable/ks"
tools:context=".MainActivity2"
tools:ignore="MissingClass">
<ImageView
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/ks"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="63dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
при сборке приложения и передаче его на телефон фон просто остается белым. в activity_main.xml в тэге ImageView ничего не отображается, хотя в constraintlayout все видно как надо.
как же мне поставить картинку на фон приложения?