基本上我希望能夠隨意調整我的TouchOpacity
組件不透明度。手動設置TouchOpacity的不透明度
這裏是我的代碼
<TouchableOpacity
className='Calculator'
style={
[
styles.container,
{
transform:[
{translateX:this.props.anim.x}
],
}
]
}
onPress={this.hideKeyboard}
activeOpacity={1}
>
<AmountInput />
</TouchableOpacity>
);
只給一些背景: AmountInput
是一個基本的文本輸入框。
我正在使用TouchableOpacity
來按下時隱藏鍵盤。不過,我不希望它在印刷機上改變不透明度,我嘗試使用TouchableWithoutFeedback
,但它的onPress
事件無法與TextInput
正常工作。
因爲我爲它的預期目的(改變觸摸不透明度)我有activeOpacity
設置爲1
我不使用TouchOpacity
。這是重寫風格,但如果我擺脫它,比輸入框更改不透明當我觸摸它的容器!
任何人都知道解決的辦法?我有一個opacity
變量被傳遞給道具。
編輯: 下面是使用TouchableWithoutFeedback
<TouchableWithoutFeedback
className='Calculator'
style={
[
styles.container,
{
opacity:1,
backgroundColor:'red',
transform:[
{translateX:this.props.anim.x}
],
}
]
}
onPress={this.hideKeyboard}
>
<AmountInput />
</TouchableWithoutFeedback>
但由於某些原因,所有我在標籤定義的屬性似乎都沒有影響一些代碼,我的backgroundColor
樣式設置爲red
它沒有做任何事情。