React Native - Vertical align image with resizeMode “contain”

前端 未结 5 1288
囚心锁ツ
囚心锁ツ 2021-02-02 06:41

When an image has a resize mode \"contain\" it seems to align/justify the actual image in the center, the image content however is aligned/justified at flex start.



        
5条回答
  •  太阳男子
    2021-02-02 06:50

    Using resizeMethod="resize"

    I've found a solution that doesn't requires any extra tags or tricks. Just one single prop.

    Lore

    I had the same issue because my image on remote is @3x the regular size. And once loaded on the phone with { height: 100, width: 300, resizeMode: 'contain' } styling values, it centered automatically.

    Example

    To fix it, I've just added the prop resizeMethod like the following :

    
    

    Hope it helps!

提交回复
热议问题