Generate Random Color - Android Studio - Compose
Generate random color(s) using Android Studio and Jetpack Compose There may be some situations in which you need the feature to generate a random color. For example, in a list of items, if you want to assign different colors to each item/row, you may have seen the WhatsApp Group Chat List, where each person's name is displayed in a different color. I'll do it using a button click. You can do it according to your requirements/needs. >> View for Java >> View for Kotlin >> View for Compose Code Code Snippet val generatedColor = Color( Random. nextInt ( 256 ), Random. nextInt ( 256 ), Random. nextInt ( 256 ) ) Full Example MainActivity.kt package com.technifysoft.myapplication import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.background import androidx.compose...