无论什么情况,都可以在固定的屏幕位置显示本机组件

时间:2019-06-26 18:13:43

标签: android react-native react-native-android expo

我想在React Native应用程序的屏幕上放置一个组件,在这种情况下为可单击的简单文本应用程序版本号,并将强制刷新版本。无论应用程序运行在哪个平台上(iOS / Android / device / simulator / react-native-web),无论应用程序屏幕上发生了什么,我都希望此可见。如果显示其他内容,我希望此组件显示在它们之上。我无法做到这一点。

(此外:这是用于调试,因为我还没有发现Expo系统能够可靠地重新加载并显示该应用程序的当前版本。如果有人想对此提出评论,那就太好了。)

例如,我尝试了很多事情,包括主app.js文件中的以下组件。在这种情况下,它将在iOS模拟器上的所有屏幕上显示,但不会在Android设备上显示。从其他帖子中,我了解到这可能与Android的限制有关。

谢谢您的帮助。

import React, { Component } from 'react'
import { StyleSheet, Text, View,TouchableHighlight } from 'react-native'
import { Ionicons } from '@expo/vector-icons'
import { Updates } from 'expo';

export default class AppVersion1 extends Component {
    _onPressButton = ()=> {
        AppConsole.log('Pressed reload')
        Updates.reload()
    }

    render(){

        return(<View style={styles.appVersionPosition}>
            <TouchableHighlight onPress={this._onPressButton}>
            <Text
                style={styles.appversion}
                onPress={this.reload}
            >
                <Ionicons name="md-refresh" /> Beta043</Text>
            </TouchableHighlight>
        </View>)}
}

const styles = StyleSheet.create({
    appversion: {
        color:'white',
        backgroundColor:'#68a0cf',
        textAlign: 'center',
        fontSize:10,
        zIndex: 99999
    },
    appVersionPosition: {
        position: 'absolute',
        top: '7%',
        left: 0,
        backgroundColor: 'grey',
        zIndex: 99999
    }
})

0 个答案:

没有答案
相关问题