1
画像とテキストを中心にしたボタンがあります。 ボタンは画面の下部に配置されています。反応したネイティブのボタンと画像の中心を合わせる
私はこのコードを持っている:https://i.stack.imgur.com/jFWAy.png
あなたはこの動作について何を知っていますか:
<TouchableOpacity style={Styles.oneButton}>
<View style={Styles.oneButtonView}>
<Text style={Styles.payTextDollar}>
<Image
style={Styles.imageButton}
source={props.image}
/>
Pay
</Text>
</View>
</TouchableOpacity>
oneButton: {
height: 60,
backgroundColor: '#e41c23',
}
oneButtonView: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
height: 20,
justifyContent: 'center',
}
payTextDollar: {
flex: 1,
color: '#ffffff',
fontSize: 20,
fontFamily: 'MetaOffc-Light',
textAlign: 'center',
}
imageButton: {
marginTop: 6,
}
これは、iOSのに非常に適していますが、しかし、画像はそのように、Android上で本当に小さいのですか? 画像とテキストをボタンの中央に配置する別の方法があるかどうかをご存知でしょうか。https://i.stack.imgur.com/geBSz.png
ありがとう!
私の投稿を編集しました。イメージスタイルを追加しました。私はテキストでイメージを置くことは慣習ではないことを知っていますが、私はそれを外に置くと、すべてをボタンの中央に置くことはできません。 – Kazuwa
@ Kazuwa imageButtonスタイルに高さと幅を与えたい場合があります。また、自分のスタイルのresizeModeや、 コンポーネントを使ってスケーリングを処理する方法も見てください。 –
basudz