A simple Android app, written using Jetpack Compose, that shows and lets you search all icons from
androidx.compose.material:material-icons-extended
Append these lines to module dependencies:
implementation "androidx.compose.compiler:compiler:$compose_version"
implementation "androidx.compose.material3:material3:1.0.0-rc01"
implementation "androidx.compose.ui:ui:1.3.0-rc01"
debugImplementation "androidx.compose.ui:ui-tooling:1.2.1"
implementation 'com.github.Husseinfo:material-icons-extended-search:1.0.1'
Append this lines to repositories
:
maven { url "https://jitpack.io" }
Append these lines to android section:
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
}
Add a compose view to your XML layout:
<androidx.compose.ui.platform.ComposeView android:id="@+id/compose_view" android:layout_width="30dp"
android:layout_height="30dp" />
val resultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val icon = getIconByName(this, result)
Snackbar.make(
window.decorView.findViewById(android.R.id.content),
iconName.iconName, Snackbar.LENGTH_SHORT
).show()
findViewById<ComposeView>(R.id.compose_view).setContent {
MaterialTheme(
colorScheme = getAppColorScheme(
this,
isSystemInDarkTheme()
)
) {
Surface {
Icon(
modifier = Modifier.size(40.dp),
imageVector = icon,
contentDescription = icon.name
)
}
}
}
}
}
resultLauncher.launch(Intent(this, MaterialIconSelectorActivity::class.java))