首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >以hr为中心的react本机图标

问以hr为中心的react本机图标
EN

Stack Overflow用户
提问于 2018-04-03 14:35:02
回答 2查看 522关注 0票数 2

我想设计一条横线,上面有一个图标,比如这一个,但是在react本机中。朝以下方向发展的事物:

代码语言:javascript
复制
<View style={{}}>
  <View style={{}}>
  <Image style={{}} source={}/>
</View>

​

我该怎么做?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-03 16:11:42

试试这段代码

代码语言:javascript
复制
import React, { Component } from 'react';
import { StyleSheet, View, Image } from 'react-native';

export default class App extends Component {
  render() {
    return (
      <View style={{ paddingTop: 100, alignItems: 'center' }}>
        <View style={{ borderBottomColor: '#bdbdbd', borderBottomWidth: 1, width: '90%' }} />
        <View style={{ position: 'relative' }}>
          <Image
            style={styles.image}
            source={{
              uri: 'http://www.cgbconstrucciones.com/en/templates/rt_clarion/images/icons/green-leaf-icon.png',
            }}
          />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  image: {
    width: 40,
    height: 40,
    position: 'absolute',
    top: -20,
    left: -20,
    backgroundColor: '#fff'
  }
});

查看这里的演示,https://snack.expo.io/@raajnadar/absolute-position

票数 2
EN

Stack Overflow用户

发布于 2018-04-03 17:09:39

代码语言:javascript
复制
<View style={{flexDirection: 'row', alignItems: 'center'}}>
      <View style={{flex: 1, borderBottomColor: '#bdbdbd', borderBottomWidth: 1}} />
      <Image style={{width: 40, height: 40}}
        source={{
          uri: 'http://www.cgbconstrucciones.com/en/templates/rt_clarion/images/icons/green-leaf-icon.png',
        }}/>
      <View style={{flex: 1, borderBottomColor: '#bdbdbd', borderBottomWidth: 1}} />
    </View>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49632734

复制
相关文章

相似问题

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