第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在淺藍(lán)色 flexbox 中居中文本?

如何在淺藍(lán)色 flexbox 中居中文本?

桃花長(zhǎng)相依 2021-11-04 15:19:25
import React, { Component } from 'react';import { View, Text, FlatList, TouchableOpacity, Dimensions, StyleSheet } from 'react-native';const data = [    {id: 'Music', value: 'Music'},    {id: 'Events', value: 'Events'},    {id: 'About Us', value: 'About Us'},    {id: 'Benefits', value: 'Benefits'},    {id: 'Account', value: 'Account'},    {id: 'Social Media', value: 'Social Media'},    {id: 'FAQ', value: 'FAQ'},    {id: 'Settings', value: 'Settings'}  ];const numColumns = 2;const size = Dimensions.get('window').width/numColumns;  export const Grid = () => {    return (        <FlatList          style={{ marginTop: 20 }}          data={data}          renderItem={({item}) => (            <TouchableOpacity style={styles.itemContainer}>              <Text style={styles.item}>{item.value}</Text>            </TouchableOpacity>          )}          keyExtractor={item => item.id}          numColumns={numColumns} />      );}const styles = StyleSheet.create({    itemContainer: {      width: size,      height: size    },    item: {      flex: 1,      margin: 15,      fontSize: 25,      fontWeight: 'bold',      color: 'white',      backgroundColor: 'lightblue'    }  });我嘗試在子視圖和父視圖中使用 justifyContent: "center" 但它不起作用。textAlign: "center" 能夠水平對(duì)齊文本。
查看完整描述

3 回答

?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個(gè)贊

像這樣嘗試。


export const Grid = () => {

    return (

        <FlatList

          style={{ marginTop: 20 }}

          data={data}

          renderItem={({item}) => (

            <TouchableOpacity style={styles.itemContainer}>

              <View style={styles.item}>

                <Text style={styles.itemText}>{item.value}</Text>

              </View>

            </TouchableOpacity>

          )}

          keyExtractor={item => item.id}

          numColumns={numColumns} />

      );

}


const styles = StyleSheet.create({

    itemContainer: {

      width: size,

      height: size

    },

    item: {

      flex: 1,

      justifyContent: 'center',

      alignItems: 'center',

      margin: 15,

      backgroundColor: 'lightblue'

    },

    itemText: {

      fontSize: 25,

      textAlign: 'center',

      fontWeight: 'bold',

      color: 'white',

    }

  });


查看完整回答
反對(duì) 回復(fù) 2021-11-04
?
冉冉說(shuō)

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊

您的 itemContainer 類(lèi)缺少該display: flex屬性。這是在 flex 項(xiàng)目上使用 flexbox 屬性所必需的。


查看完整回答
反對(duì) 回復(fù) 2021-11-04
?
PIPIONE

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超9個(gè)贊

請(qǐng)附上截圖,詢(xún)問(wèn)有關(guān)在 React Native 中進(jìn)行設(shè)計(jì)的問(wèn)題。來(lái)到答案你可以試試這個(gè)。


item:{

      alignSelf: 'center',

      flex: 1,

      margin: 15,

      fontSize: 25,

      fontWeight: 'bold',

      color: 'white',

      backgroundColor: 'lightblue'

},

itemContainer: {

      width: size,

      height: size,

      justifyContent: 'center',

      alignItems: 'center'

},


查看完整回答
反對(duì) 回復(fù) 2021-11-04
  • 3 回答
  • 0 關(guān)注
  • 172 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)