首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >React-本地化身。修复ImageRadius以使所有头像平等

React-本地化身。修复ImageRadius以使所有头像平等
EN

Stack Overflow用户
提问于 2019-05-20 17:36:18
回答 1查看 238关注 0票数 0

仅在renderItem和FlatList中聚焦。头像是这样显示的。

有些是圆圈,有些是圆角,defaultSource头像是正方形。

似乎找不到解决方案..

我尝试过使用borderRadius作为图像道具,而不是使用inside of the Image样式。

代码语言:javascript
复制
renderItem = ({item}) => (
        <ListItem
            bottomDivider={true}
            Component={TouchableScale}
            friction={90}
            tension={100}
            activeScale={0.95}
            title={item.name}
            titleStyle={styles.titleStyle}
            subtitle={item.email}
            subtitleStyle={styles.subStyle}
            leftAvatar={<Image source={{uri: 'my URL'}}
                               defaultSource={require('../resources/defaultAvatar.png')}
                               style={{width: 45, height: 45, borderRadius: 80}}
                               resizeMode={'contain'}/>}
            onPress={() => this.onUserPress(item)}
            chevronColor="white"
            chevron
        />
    )

    render() {
        const {search} = this.state;
        return (
            <View>
                <SearchBar
                    platform={"ios"}
                    ref={search => this.search = search}
                    placeholder={'Escrever aqui...'}
                    color={'#808080'}
                    onChangeText={this.SearchFilterFunction}
                    value={search}
                    round={true}
                    inputStyle={{fontSize: 16}}
                    inputContainerStyle={{height: 35}}
                    containerStyle={{height: 53}}
                    showLoading={true}
                />
                <FlatList
                    data={this.state.usersFilter.sort((a, b) => a.name.toString().localeCompare(b.name))}
                    renderItem={this.renderItem}
                    keyExtractor={this.keyExtractor}
                />
            </View>
        );
    }

我希望所有的头像都被正确格式化。

我在评论中上传了app print!

EN

回答 1

Stack Overflow用户

发布于 2019-05-21 22:05:25

代码语言:javascript
复制
import { Platform } from 'react-native';

borderRadius: Platform.OS === 'ios' ? 60 : 100

试试这个,它对我来说很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56218120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档