Uncategorized

React Native: ActivityIndicator

In React Native, an ActivityIndicator displays a loading circular mark which signals to the user that a task is being performed or a network request is being made.

Using ActivityIndicators in software development is a good practice and provides a good user experience to users of your application, and when you’re working with React Native apps, there’s a way to show such indication.

Let’s Get Started

The first thing to do is to import ActivityIndicator and other components like View and Text from React Native.

import React from "react";
import { ActivityIndicator, StyleSheet, Text, View } from "react-native";

Next, call your ActivityIndicator component like so.

import React from "react";
import { ActivityIndicator, StyleSheet, Text, View } from "react-native";

class App extends Component {
render(){
render(
<View>
 <ActivityIndicator size="small" color="#0000ff" />
</View>
)
}
}
}

The size property tells whether the indicator should be “small” or “large”.

The color property defines the color of the indicator. If you fail to define a specific color, you might get some display on iOS, but you won’t see any rendering for Android.

Positioning ActivityIndicator

You can set position of your ActivityIndicator by defining some styles using the style tag.

import React from "react";
import { ActivityIndicator, StyleSheet, Text, View } from "react-native";

class App extends Component {
render(){
render(
<View>
 <ActivityIndicator size="small" 
style={{marginLeft: 0,
        top: 0,
        bottom: 0,
        alignSelf: 'center',
        right:0,
        left:0
}} 
        color="#0000ff" 
/>
</View>
)
}
}
}

export default App

Read React Native docs

Author

Recent Posts

Google Launches Its Own ‘Reasoning’ AI Model to Compete with OpenAI

This month has been packed for Google as it ramps up efforts to outshine OpenAI…

2 days ago

You can now use your phone line to call ChatGPT when cellular data is unavailable.

OpenAI has been rolling out a series of exciting updates and features for ChatGPT, and…

3 days ago

Phishers use fake Google Calendar invites to target victims

A financially motivated phishing campaign has targeted around 300 organizations, with over 4,000 spoofed emails…

4 days ago

Hackers Exploiting Microsoft Teams to Remotely Access Users’ Systems

Hackers are exploiting Microsoft Teams to deceive users into installing remote access tools, granting attackers…

5 days ago

Ethical Hacking Essentials

Data plays an essential role in our lives.  We each consume and produce huge amounts…

7 days ago

Thomas E. Kurtz, co-creator of the BASIC programming language, passes away at 96.

Thomas E. Kurtz, co-creator of the BASIC programming language, passed away on November 12, 2024,…

7 days ago