我正在玩反應本機,並得到了一個奇怪的行爲。ReactNative ActivityIndicator不顯示動畫屬性啓動虛假時
當我試圖表明一個ActitvityIndicator爲Android其動畫屬性設置爲true,在狀態的showProgress
變量如果變量開始爲假這是行不通的。
在下面的示例中,如果ActivityIndicator動畫屬性的起始值爲true,那麼按鈕會使ActivityIndicator隱藏或正確顯示。
import React, { Component } from 'react';
import {
Text,
View,
StyleSheet,
TextInput,
TouchableHighlight,
ActivityIndicator
} from 'react-native';
export class Login extends Component {
constructor(props) {
super(props);
this.state = {
showProgress: true
};
}
render() {
return (
<View>
<TouchableHighlight onPress={this.progressOff.bind(this)}>
<Text>progressOff</Text>
</TouchableHighlight>
<TouchableHighlight onPress={this.progressOn.bind(this)}>
<Text>progressOn</Text>
</TouchableHighlight>
<ActivityIndicator animating={this.state.showProgress} size="large"/>
</View>
);
}
progressOff() {
this.setState({showProgress: false});
}
progressOn() {
this.setState({showProgress: true});
}
}
但是,如果使用下面的代碼,用動畫屬性起假,那麼按鈕使ActivityIndicator出現不工作:
import React, { Component } from 'react';
import {
Text,
View,
StyleSheet,
TextInput,
TouchableHighlight,
ActivityIndicator
} from 'react-native';
export class Login extends Component {
constructor(props) {
super(props);
this.state = {
showProgress: false
};
}
render() {
return (
<View>
<TouchableHighlight onPress={this.progressOff.bind(this)}>
<Text>progressOff</Text>
</TouchableHighlight>
<TouchableHighlight onPress={this.progressOn.bind(this)}>
<Text>progressOn</Text>
</TouchableHighlight>
<ActivityIndicator animating={this.state.showProgress} size="large"/>
</View>
);
}
progressOff() {
this.setState({showProgress: false});
}
progressOn() {
this.setState({showProgress: true});
}
}
缺少什麼我在這裏?
是,對於IOS? https://facebook.github.io/react-native/docs/activityindicator.html#hideswhenstopped。默認情況下,它在動畫設置爲假時隱藏 –
我有同樣的問題,無法正常工作。當狀態爲假時,我最終在視覺上隱藏了指示符('{height:0}')。 – zvona