【问题标题】:React Native elevation and position absoluteReact Native 高度和绝对位置
【发布时间】:2019-01-20 02:33:09
【问题描述】:

尝试将elevation(阴影)添加到View 有效,但是我的第二个View 渲染了圆圈,隐藏在View 下并带有elevation 属性。如果elevation 被删除,带有position: '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',
  }    
});

【问题讨论】:

    标签: react-native-android elevation


    【解决方案1】:

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

    【讨论】:

    • 我遇到了同样的问题。我想处理它的最好方法是使用 Photoshop 或 xd 或类似的东西给底部视图以高程外观....希望有更好的方法
    【解决方案2】:

    也为圆添加阴影并将圆的阴影级别增加 1。因此,在您的情况下,为圆添加高程 4。

    【讨论】:

      猜你喜欢
      • 2011-09-27
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 2015-11-17
      • 1970-01-01
      相关资源
      最近更新 更多