Fix Resource loading above API 25 on SplashScreen Compose
This commit is contained in:
parent
bdc3f1560f
commit
78e88b5418
1 changed files with 8 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package org.fnives.test.showcase.compose.screen.splash
|
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.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
|
@ -16,8 +18,13 @@ import org.fnives.test.showcase.R
|
||||||
@Composable
|
@Composable
|
||||||
fun SplashScreen() {
|
fun SplashScreen() {
|
||||||
Box(Modifier.fillMaxSize().background(colorResource(R.color.purple_700)), contentAlignment = Alignment.Center) {
|
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(
|
Image(
|
||||||
painter = painterResource(R.mipmap.ic_launcher_round),
|
painter = painterResource(resourceId),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.size(120.dp)
|
modifier = Modifier.size(120.dp)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue