2016-01-27 35 views
36

リアクトネイティブでは、borderRadiusは機能していますが、ボタンに与えられた背景色は四角いままです。ここで何が起こっているのですか?ネイティブボーダー半径と背景色の反応

JS

<TouchableHighlight 
    style={styles.submit} 
    onPress={() => this.submitSuggestion(this.props)} 
    underlayColor='#fff'> 
    <Text style={[this.getFontSize(),styles.submitText]}>Submit</Text> 
</TouchableHighlight> 

スタイル

... 
submit:{ 
    marginRight:40, 
    marginLeft:40, 
    marginTop:10, 
}, 
submitText:{ 
    paddingTop:20, 
    paddingBottom:20, 
    color:'#fff', 
    textAlign:'center', 
    backgroundColor:'#68a0cf', 
    borderRadius: 10, 
    borderWidth: 1, 
    borderColor: '#fff' 
}, 
... 

enter image description here

+0

ただの推測、 'のborderStyleを与えることを試してください:あなたがテストしている、残念ながら – Cherniv

+0

いいえ、それdidntの仕事に「solid''?イオスかアンドロイド? – Chipe

+0

た環境に' submitText' – Cherniv

答えて

57

TouchableHighlight自体にボタンのスタイルを移動してみてください:

スタイル:

submit:{ 
    marginRight:40, 
    marginLeft:40, 
    marginTop:10, 
    paddingTop:20, 
    paddingBottom:20, 
    backgroundColor:'#68a0cf', 
    borderRadius:10, 
    borderWidth: 1, 
    borderColor: '#fff' 
    }, 
    submitText:{ 
     color:'#fff', 
     textAlign:'center', 
    } 

ボタン(同):

<TouchableHighlight 
    style={styles.submit} 
    onPress={() => this.submitSuggestion(this.props)} 
    underlayColor='#fff'> 
    <Text style={[this.getFontSize(),styles.submitText]}>Submit</Text> 
</TouchableHighlight> 

enter image description here

+1

ありがとう! 'パディング'も重要な鍵です。 – DazChong

27

あなたがあなたのスタイルにoverflow: hiddenを追加する必要がありますreact-native-buttonを使用する場合:

のJs:

import Button from 'react-native-button'; 

<Button style={styles.submit}>Submit</Button> 

スタイル:

submit { 
    backgroundColor: '#68a0cf'; 
    overflow: 'hidden'; 
} 
+3

'overflow: 'hidden'は反応なしでも私のために働いたネイティブボタン –

+1

ありがとう。はい、コンテナに 'backgroundColor'と' borderRadius'を置いて、コンテナに 'overflow: 'hidden''を追加してくれました。 ( 'react-native-button'も使用していません) – David

+0

これは私が欲しかったものです! (チェックされていないもの) –

関連する問題