反应本地高程和绝对位置 [英] React Native elevation and position absolute

查看:100
本文介绍了反应本地高程和绝对位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将elevation(阴影)添加到View可行,但是我的第二个View渲染圆,隐藏在View下并带有elevation属性.如果删除了elevation,则用position: 'absolute'圈出的圆圈就可以正常工作.

Trying to add elevation (shadow) to View works, however my second View, which renders circle, hides under View with elevation property. If elevation is removed, circle with position: 'absolute' is working properly.

任何想法如何使用绝对高程和位置视图?

Any ideas how to use elevation and position View absolute?

我的代码:

import React, { Component } from 'react';
import { StyleSheet, Text, View, Platform, TouchableOpacity } from 'react-native';
import { Font } from 'expo';


export default class Position extends Component {
  render() {
    return (
      <View style={{ flex: 1, marginTop: 25 }}>
        <View style={{ height: 50, backgroundColor: 'red', elevation: 3}}/>
        <View style={styles.circle}><Text>HELLO</Text></View>  
    </View>
    );
  }
}
const styles = StyleSheet.create({
  circle: {
    position: 'absolute',
    backgroundColor: 'yellow',
    width: 60,
    height: 60,
    top: 30,
    borderRadius: 100,
    alignSelf: 'center',
    justifyContent: 'center',
    alignItems: 'center',
  }    
});

推荐答案

通过将elevation添加到圆圈View来找到分辨率.

Found resolution by adding elevation to circle View as well.

这篇关于反应本地高程和绝对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆