首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在边框和图像之间添加空白: React本机

在边框和图像之间添加空白: React本机
EN

Stack Overflow用户
提问于 2020-06-25 13:03:22
回答 1查看 1.2K关注 0票数 0

我正试着让我的触手可及的按压有一个边界。我可以这样做,但我正在寻找如何在边框和圆圈之间添加空白。

示例:

我现在拥有的是:

代码语言:javascript
运行
复制
colorPicker: {

        flex: 4,
        flexDirection: 'row',
        alignSelf: 'flex-start',
        width: '88%',
        paddingLeft: 16,
    },

circle: {
        position: 'relative',
        height: 40,
        width: 40,
        borderRadius: 40,
        margin: 10,
        borderColor: '#757083',
        borderWidth: 2,
    }

<View style={styles.colorPicker}>
   <TouchableWithoutFeedback
    style={[styles.circle, { backgroundColor: '#090C08' }]}
    onPress={() => this.setState({ color: '#090C08' })}/>

我试过几件事,但没有一件能接近我。有办法增加两个边框吗?我试着用垫子,它什么也不做,我摆弄边缘和半径,但也什么也没有。谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-25 13:26:12

我试过用TouchableWithoutFeedback,但没有用。但是,一个可触摸的不透明度可以很容易地样式,所以这是与TouchableOpcity的版本。诀窍是在内部视图中使用,并为外部视图填充或为内部视图设置边距。

代码语言:javascript
运行
复制
<View style={styles.colorPicker}>
  <TouchableOpacity
    style={{
      backgroundColor: 'white',
      alignSelf: 'center',
      borderRadius: 40,
      borderColor: '#757083',
      borderWidth: 2,
    }}
    onPress={() => {}}>
    <View style={[styles.circle, { backgroundColor: '#090C08' }]}>
    </View>
  </TouchableOpacity>
</View>

样式

代码语言:javascript
运行
复制
  colorPicker: {
    flex: 4,
    flexDirection: 'row',
    alignSelf: 'flex-start',
    width: '88%',
    paddingLeft: 16,
    backgroundColor: 'red',
  },

  circle: {
    position: 'relative',
    height: 40,
    width: 40,
    borderRadius: 40,
    margin:5
  },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62576027

复制
相关文章

相似问题

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