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?

アプリの画面にgoogleのマテリアルアイコンを表示させたい

Posted at

インターネットの通信部分で色々うまくいかず悩んでます。
通信エラーになったとき、わかりやすくエラーや画像が壊れいるアイコンを表示させたいなぁと考え、googleのマテリアルアイコンを使おうとなりました。

が、しかしいつものごとく、あれ?どうやるんだ???となり:joy:
自分メモ残しておこう💦

1.「res」フォルダ右クリック→New→VectorAsset

image.png

2.アイコンマークをクリック

image.png

3.いっぱいアイコンが出てくるので、検索窓にそれっぽい単語の一部を入力。

 今回は壊れている画像にしたいので、「broken」などと。
 これ!というアイコンを見つけたらクリックで選択、OKボタンクリック。
image.png

4.名前、サイズ、色、透明度を決めて、Nextボタンをクリック。

 Enable auto mirroring for RTL layoutには、通常チェックは入れない。
 (チェックを入れると矢印などの向きが左右反転します)
image.png

5.最後に、データの保存場所を確認してFinish

指定の場所にxmlファイルが作成されます:ok_hand:
image.png

6.画面から呼び出す。

MainActivity.kt
@Composable
fun TestScreen(modifier: Modifier=Modifier) {
    Image(
        painter = painterResource(R.drawable.baseline_broken_image_24),  //画像指定
        contentDescription = "エラー画像",
        modifier=modifier
    )
}
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?