React Native elevation and position absolute

孤街浪徒 提交于 2019-12-24 18:42:55

问题


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?

My Code:

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',
  }    
});


回答1:


Found resolution by adding elevation to circle View as well.



来源:https://stackoverflow.com/questions/51821016/react-native-elevation-and-position-absolute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!