28
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

react nativeのImageのresizeModeについてメモ (初心者向け)

Last updated at Posted at 2019-03-14

react nativeで画像の横幅、縦幅を決定するには、heightとwidthを指定すれば良いが、
画像の縦横比率を変えるにはresizeModeプロパティを指定する必要がある。

以下のように使う。


<Image
  style={{width: 100, height: 50}}
  resizeMode='contain'
  source={{uri: 'https://facebook.github.io/react-native/docs/assets/favicon.png'}}
/>

resizeModeで指定できる文字
1.cover 指定したheightとwidthのうち、大きい数値に合わせ画像が大きくなります。 画像の縦横比は崩れません。
2.stretch 指定したheightとwidthに合わせて画像が大きくなります。画像の縦横比は崩れます。
3. contain 指定したheightとwidthのうち、小さい数値に合わせて画像をリサイズします。 画像の縦横比は崩れません

以下はぼ使わない。
center 使い道はない。
repeat: 一枚の画像を、一画面に何個も表示する。使い道はない。

28
20
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
28
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?