android - 当设备旋转时,React Native 组件不居中
问题描述
我是 React-Native 的新手,并且停留在这一点上。我有一个像这样的浮动操作按钮:
import {FloatingAction} from 'react-native-floating-action';
{other imports...}
export default Modules = ({navigation}) => {
{some variables...}
return (
<SafeAreaView
style={{
backgroundColor: constants.darkGreyColor,
flex: 1,
}}>
{other components...}
<FloatingAction
visible={flatListYOffset >= windowDimensions.height * 0.5}
position="center"
distanceToEdge={windowDimensions.height * 0.05}
onPressMain={() =>
flatListRef.current.scrollToOffset({
animated: true,
})
}
floatingIcon={scrollTopIcon}
color={constants.darkPurpleColor}
showBackground={false}
/>
</SafeAreaView>
);
};
但是当旋转设备时: 它变成了这样,不得不重新加载我的应用程序而不改变设备的旋转来解决它。但是每次当设备相对于其初始位置旋转时都会发生这种情况。不管它在启动时处于哪个位置。我应该怎么办 ?
编辑
位置为“右”或“左”时没有问题。它位于设备的两侧,但无法计算“中心”。
解决方案
推荐阅读
- laravel - 从 Blade-Files 渲染 PHP、SCSS、JS、Blade-Files
- javascript - 在 Vite2 中,如何在 tailwind.config.js 中导入 ESModule
- angular-cli - 出现“发生未处理的异常:尝试运行“ng serve”时找不到模块'@angular/compiler-cli'
- c++ - 安全编码实践
- excel - 有没有办法在excel vba中使用没有循环的进度条?
- python - python - ast 识别导入的名称
- python - Psycopg2 未安装在 Mac M1 上
- javascript - Javascript click Event only Triggers on Page Reload 然后不起作用
- mongodb - 无法连接到从 docker-compose 运行的 MongoDB
- amazon-dynamodb - DynamoDB 中的多个可选查询参数