DevLog
Python, TypeScript, etc...
MyPage
Python, TypeScript, etc...
2022/07/19

Androidで画像のアスペクト比を保ちつつ画面いっぱいに表示

Android
preview
@shiromisanta
Frontend Engineer
  •  /
目次
解決策

解決策

ImageViewにandroid:adjustViewBounds="true"を設定する。

すると横幅いっぱいに表示した上でアスペクト比を保ちつつ高さを自動設定してくれる。

<ImageView android:id="@+id/imageView" android:layout_width="0dp" android:layout_height="wrap_content" android:adjustViewBounds="true" tools:src="@tools:sample/avatars" />

関連記事

preview
@shiromisanta 2022/08/18
光学カメラAndroidKotlin
preview
@shiromisanta 2022/07/15
AndroidKotlin
preview
@shiromisanta 2022/07/15
AndroidKotlin
preview
@shiromisanta 2022/07/02
AndroidKotlin
2022/07/19

Androidで画像のアスペクト比を保ちつつ画面いっぱいに表示

Android

解決策

ImageViewにandroid:adjustViewBounds="true"を設定する。

すると横幅いっぱいに表示した上でアスペクト比を保ちつつ高さを自動設定してくれる。

<ImageView android:id="@+id/imageView" android:layout_width="0dp" android:layout_height="wrap_content" android:adjustViewBounds="true" tools:src="@tools:sample/avatars" />

関連記事

preview
@shiromisanta
Frontend Engineer
  •  /
目次
©︎Devlog