Fix Resource loading above API 25 on SplashScreen Compose

This commit is contained in:
Gergely Hegedus 2022-04-13 20:06:06 +03:00
parent bdc3f1560f
commit 78e88b5418

View file

@ -1,5 +1,7 @@
package org.fnives.test.showcase.compose.screen.splash
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
@ -16,8 +18,13 @@ import org.fnives.test.showcase.R
@Composable
fun SplashScreen() {
Box(Modifier.fillMaxSize().background(colorResource(R.color.purple_700)), contentAlignment = Alignment.Center) {
val resourceId = if (VERSION.SDK_INT >= VERSION_CODES.N) {
R.drawable.ic_launcher_foreground
} else {
R.mipmap.ic_launcher_round
}
Image(
painter = painterResource(R.mipmap.ic_launcher_round),
painter = painterResource(resourceId),
contentDescription = null,
modifier = Modifier.size(120.dp)
)