已解決:在底部中心反應本機組件

主要問題是底部中心的 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 的佈局模塊,可以輕鬆創建靈活且響應迅速的佈局。 它允許您指定哪些組件應該拉伸,哪些應該壓縮,並且它提供了多種選項來控制佈局的呈現方式。

相關文章:

發表評論