0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Compose for DesktopでMaterial Iconを使う

Posted at

背景

検索しても一件しかヒットしなかったので

引用元(というか参考)
https://stackoverflow.com/questions/72060687/compose-desktop-how-to-access-extended-material-icon-set

実装イメージ

image.png

実装方法

build.gradle.ktsファイルのdependenciesに以下を記載するだけでした。

implementation(compose.materialIconsExtended)

libs.versions.tomlに追記等不要でした。

実装サンプル

動作確認中の作成物コピペなので関数名など不自然ですが以下で完全に動作します。
追加の依存関係、モジュール、ライブラリはなくて動作します。
MaterialThemeでのラップは必要です。
結果は上記の実装イメージの通りです。

@Composable
fun RowMenu(
    onNext: () -> Unit,
    onBack: () -> Unit,
) {
    Box {
        Row(
            modifier = Modifier
                .align(Alignment.BottomCenter)
                .padding(16.dp)
                .background(
                    color = MaterialTheme.colorScheme.primaryContainer,
                    shape = RoundedCornerShape(12.dp) // 角丸の大きさ
                ) // 背景色
        ) {
            IconButton(onClick =  onNext ) {
                Icon(
                    imageVector = Icons.Filled.Edit,
                    contentDescription = "Edit",
                    tint = MaterialTheme.colorScheme.primary // ここで色を指定
                )
            }

            IconButton(onClick =  onBack ) {
                Icon(
                    imageVector = Icons.Filled.Delete,
                    contentDescription = "Delete",
                    tint = MaterialTheme.colorScheme.primary
                )
            }

        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?