React Native - ActivityInicator

React Native - ActivityInicator 首页 / React Native入门教程 / React Native - ActivityInicator

ActivityIndi​​cator用于显示圆形加载指示器。

PropsDescription
animating显示指示器(默认为true)或隐藏指示器(false)的选项。
size设置指标的大小(“small",“large",number), 默认为small。number格式仅在android中支持。
color设置前景色(默认为gray)。
hidesWhenStopped它提供了在没有动画时显示或隐藏指示器的选项(默认为true)。

ActivityIndicator示例

在此示例中,动画属性将活动指示器设置为true,并且在屏幕上可见。装入组件后,将使用closeActivityIndi​​cator()在六秒钟后关闭动画指示器。

import React, { Component } from 'react'
import {
    ActivityIndicator,
    AppRegistry,
    StyleSheet,
    Text,
    View,
} from 'react-native'

export default class ActivityIndicatorDemo extends Component {
    state = { animating: true }
    closeActivityIndicator = () => setTimeout(() => this.setState({
        animating: false }), 6000)
    componentDidMount = () => this.closeActivityIndicator()
    render() {
        const animating = this.state.animating
        return (
            <View style={[styles.container, styles.horizontal]} >
                <ActivityIndicator  animating = {animating} size="large" color="#ff0000" />
                <ActivityIndicator size="small" color="#44ff00" />
                <ActivityIndicator size="large" color="#rtwrw" />
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center'
    },
    horizontal: {
        flexDirection: 'row',
        justifyContent: 'space-around',
        padding: 10
    }
})

AppRegistry.registerComponent('App', () => ActivityIndicatorDemo)

输出:

React Native ActivityIndicator

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

10x程序员工作法 -〔郑晔〕

Linux实战技能100讲 -〔尹会生〕

Linux内核技术实战课 -〔邵亚方〕

说透区块链 -〔自游〕

Redis源码剖析与实战 -〔蒋德钧〕

编程高手必学的内存知识 -〔海纳〕

自动化测试高手课 -〔柳胜〕

结构会议力 -〔李忠秋〕

工程师个人发展指南 -〔李云〕

好记忆不如烂笔头。留下您的足迹吧 :)