已解决:在底部中心反应本机组件

主要问题是底部中心的 React Native 组件不容易访问。

I'm trying to create a component at the bottom center of the screen in React Native. I've tried using <code>absolute</code> and <code>relative</code> positioning, but nothing seems to work. Here's my code:
<code>&lt;View style={{position: 'absolute', bottom: 0, alignItems: 'center'}}&gt;
  &lt;Text&gt;This is my component!&lt;/Text&gt;
&lt;/View&gt;
</code>


A:

You can use <code>flexDirection:'row'</code>,<code>justifyContent:'center'</code>,<code>alignItems:'flex-end'</code>. 

<View style={{flexDirection:'row',justifyContent:'center',alignItems:'flex-end'}}>
<Text>This is my component!</Text>
</View>

React Native 中的 Yoga 是什么

React Native 是一个使用 React 构建移动应用程序的平台。 Yoga 是一种编程语言,可帮助开发人员创建用户界面和应用程序。

什么是 Flexbox

?

Flexbox 是 React Native 的布局模块,可以轻松创建灵活且响应迅速的布局。 它允许您指定哪些组件应该拉伸,哪些应该压缩,并且它提供了多种选项来控制布局的呈现方式。

相关文章:

发表评论