ActivityIndicator的效果类似我们平时看到了loading,在android中ActivityIndicator是progressBar 的Indeterminate(false)模式,说白了就是一个半圆转啊转。
具体属性:
1、ViewPropTypes props… :包含View控件的所有属性,具体咱们看View的属性解释。
2、animating:是否显示,默认true(显示)
3、color: 指示器的颜色, ios默认为gray(#999999),android 默认使用progressBar的系统样式,取决于你设置的style。
4、size: 表示大小,可以设置的值有:
‘small’: 宽高各20
‘large’: 宽高各36
5、hidesWhenStopped:此属性只在ios生效,当停止动画的时候,是否隐藏。默认为true。
例子:
01 | import React, {Component} from 'react' ; |
08 | export default class ActivityIndicatorDemo extends Component { |
11 | <View style={{flex:1}}> |
12 | <View style={{flexDirection: 'row' }}> |
16 | <View style={{flexDirection: 'row' }}> |
18 | <ActivityIndicator style={{backgroundColor: 'blue' }}/> |
20 | <View style={{flexDirection: 'row' }}> |
21 | <Text>animating= false (隐藏):</Text> |
22 | <ActivityIndicator animating={ false }/> |
24 | <View style={{flexDirection: 'row' }}> |
26 | <ActivityIndicator color= 'red' /> |
28 | <View style={{flexDirection: 'row' }}> |
29 | <Text>size small:</Text> |
30 | <ActivityIndicator size= "small" /> |
31 | <Text>size large:</Text> |
32 | <ActivityIndicator size= "large" /> |
35 | <View style={{flexDirection: 'row' }}> |
36 | <Text>view props属性设置:</Text> |
37 | <ActivityIndicator style={{height:100,width:80,backgroundColor: 'black' }} /> |
效果图:
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!