首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >portrait在肖像锁定Android应用程序中的定位识别模型

portrait在肖像锁定Android应用程序中的定位识别模型
EN

Stack Overflow用户
提问于 2018-01-12 07:12:19
回答 1查看 2.7K关注 0票数 3

我正在开发一个反应本机应用程序,由于应用程序的性质,它通常被锁定在人像上。该应用程序在AndroidManifest.xml中使用以下标志锁定为肖像画

代码语言:javascript
复制
android:screenOrientation="portrait"

现在我想让应用程序能够在应用程序中的某个位置旋转。模式组件在反应-本机似乎是正确的选择。该模式配置如下:

代码语言:javascript
复制
<Modal
    animationType="slide"
    transparent={false}
    supportedOrientations={['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right']}  
>
    <View style={styles.modal}>
        <View>
            <TouchableHighlight onPress={() => {
                this.setState({
                    awareVisible: false
                });
            }}>
            <Text>Hide Modal</Text>
            </TouchableHighlight>
        </View>
    </View>
</Modal>

在iOS中,这很好,视图将旋转,而在安卓系统中,它什么也不做。我试着创建一个定制的Modal组件,并在Android代码中捕获它,但这对我也不起作用。

EN

回答 1

Stack Overflow用户

发布于 2019-10-07 14:35:03

你可以用反应-本土化 .因为这个项目似乎不再被维护,所以最好使用这个叉:反应-本机定位-储物柜

有了它,您只需要设置这样的东西,当您需要它时:

代码语言:javascript
复制
Orientation.unlockAllOrientations(); //this will unlock the view to all Orientations
Orientation.lockToPortrait(); //this will lock the view to Portrait
Orientation.lockToLandscapeLeft(); //this will lock the view to Landscape

我还在我的应用程序中使用过它,该应用程序被迫采用肖像模式。但我需要景观模式来查看图像画廊的图像。在这两个方面都很好: Android和IOS.

希望这能帮到你。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48221282

复制
相关文章

相似问题

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