簡體   English   中英

ToolbarAndroid 未在 React Native 中顯示

[英]ToolbarAndroid is not displaying in react native

我正在學習react-native編程,使用這個https://facebook.github.io/react-native/docs/toolbarandroid.html創建工具欄,但在我的情況下它沒有被顯示。 我無法理解我到底在做什么錯誤。

任何人都可以幫助我。

 import React, { Component } from 'react';
 import { AppRegistry, Text, View, TextInput, TouchableOpacity, ToolbarAndroid } from 'react-native';
 import { ToolBar } from 'react-native-material-design';

 class LoginComponent extends Component {
   render() {
     return (
          <View style={{flex: 1, flexDirection: 'column', margin:10}}>

            <ToolbarAndroid title="Login" titleColor="black"/>

            <TextInput style={{height: 40, borderColor:'gray', borderWidth: .5}}
                placeholder="Email address" underlineColorAndroid='transparent'/>

            <TextInput style={{height: 40, borderColor:'gray', borderWidth: .5}}
                placeholder="Password" secureTextEntry={true} underlineColorAndroid='transparent'/>

            <TouchableOpacity style={{ height: 40, marginTop: 10 , backgroundColor: '#2E8B57'}}>
                <Text style={{color: 'white', textAlign: 'center', marginTop: 10, fontWeight: 'bold'}}>LOG IN</Text>
            </TouchableOpacity>
       </View>
     );
   }
 }

 AppRegistry.registerComponent('Myntra', () => LoginComponent);

在此處輸入圖片說明

這是一個已知問題 解決方法是為 ToolbarAndroid 設置高度。

作為本機反應的新手,這是我迄今為止找到的最佳解決方案,希望它有所幫助。 https://github.com/react-native-community/toolbar-android

首先,添加npm install @react-native-community/toolbar-android --save或者 yarn lover add yarn add @react-native-community/toolbar-android

其次,運行react-native start命令。

三、運行react-native run-android

快樂編碼:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM