2017-03-28 50 views
0

我有TextInput,它應該是一個邊框,當我試圖定義邊框顏色時,它不會改變,只是保持灰色,爲什麼?爲什麼邊框的顏色不會改變?

這裏是我用來渲染的TextInput邊境代碼:

import React, {Component} from 'react'; 
import { 
    StyleSheet, View, Text, Image, TextInput, AppRegistry 
} from 'react-native'; 

class Profile extends Component { 

render() { 
     return (
      <View style={styles.profile}> 
        <View style={[styles.loginRow, {marginBottom: 8}]}> 

         <TextInput 
          style={styles.textInputValue} 
          ref={(ref) => this.password = ref} 
          onFocus={() => this.password.focus()} 
          onChangeText={(text) => this.setState({password: text})} 
          underlineColorAndroid="transparent" 
          placeholderTextColor="#ffffff" 
          placeholder='Password'/> 

        </View> 
      </View> 
); 
    } 

} 

const styles = StyleSheet.create({ 

profile: { 
     padding: 46, 
     flex: 1, 
     justifyContent: 'center', 
     alignItems: 'center', 
     backgroundColor: '#f0aa14' 
    }, 

     loginRow: { 
       height: 36, 
       flexDirection: 'row', 
       justifyContent: 'flex-start', 
       alignItems: 'center', 
       borderBottomWidth: 1, 
       borderColor: 'white', 
       borderRadius:20, 
       elevation: 1, 
       marginBottom: 25 

      }, 

     textInputValue: { 
       flex: 1, 
       alignSelf: 'center' 

      } 
    }); 


AppRegistry.registerComponent('test',() => Profile); 

我希望邊框的彩色應該是白色的,但它是灰色的,如何解決呢?

enter image description here

這是我想什麼有:

enter image description here

+0

你能添加更多的代碼嗎?爲了追蹤用戶界面問題,重建它非常重要,並且知道到底發生了什麼 – vanBrunneren

+0

@vanBrunneren剛剛添加了更多代碼 –

回答

1

可以請你在下面的風格

loginRow: { 
    height: 36, 
    flexDirection: 'row', 
    justifyContent: 'flex-start', 
    alignItems: 'center', 
    borderColor: 'white', 
    borderWidth: 1, 
    borderRadius: 20, 
    elevation: 1, 
    marginBottom: 25 

}, 

textInputValue: { 
    flex: 1, 
    marginHorizontal: 20, 
    alignSelf: 'center' 

} 

我所做的就是盡力,而不是borderBottomWidth: 1,爲loginRow類,我已更改borderWidth: 1,並在textInputValue類中添加marginHorizontal: 20,

請檢查

+0

魔法!現在它工作了!非常感謝! –

+0

另一個小問題,也許你知道,我應該改變什麼風格,所以文本將顯示在這個矩形的中心? –

+0

只需在您的TextInput中添加'textAlign = {「center」}' – vanBrunneren

相關問題