2017-01-15 4 views
0

チャットアプリで働いていて、私はgifted chatを使っています。 私のバブルにテキストとイメージの両方を入れたい。それはうまく動作しますが、私はそれが分割されている方法に満足していません...反応ネイティブチャットアプリ "スプリット"チャットバブル

私は左にテキストを、右にイメージを入れたいです。これは、バブルのコンテンツのためのコードがある enter image description here

現在、私のテキストは、画像の上にある

<TouchableOpacity key={i} style={[styles.mapView, this.props.mapViewStyle]}> 
    <View> 
    <Text style = {styles.titleText}> {title}</Text> 
    <Image style={[styles.image, this.props.imageStyle]} source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}/> 
    </View> 
</TouchableOpacity> 

私は左と上のテキストを達成することができますどのように上の任意のアイデア右の画像?

答えて

1

ビューでフレックスを使用する必要があります。https://facebook.github.io/react-native/docs/flexbox.htmlテキストとイメージに適切なアライメントを付けることもできます。デフォルトではdirectionはカラムなので、flexDirection: 'row'を使用してください 以下のコードを使用してください。

<TouchableOpacity key={i} style={[styles.mapView,  this.props.mapViewStyle]}> 
    <View style={{flex:1,flexDirection:'row'}}> 
    <View style={{flex:0.5}}> 
     <Text style = {styles.titleText}> {title}</Text> 
    </View> 

    <View style={{flex:0.5}}> 
     <Image style={[styles.image, this.props.imageStyle]} source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}/> 
    </View> 
    </View> 
</TouchableOpacity> 
+0

とよく似ています。将来の訪問者のためのOPです。回答を受け入れることの意味は何ですか? –

+1

私はそれを編集して、必要なコードを与えました。 –

+0

良い仕事、ありがとう:) –

関連する問題