rabbit87 rabbit87 - 3 years ago 113
Android Question

React Native Android Text colour not working (except Black and White)

I'm building an android app using React Native, but I have problem when it comes to setting the Text colour. I cannot seem to use other colour than Black or White. For example; using

<Text style={{color: '#ff0000'}}>Read Notice Here</Text>


would cause the text to be Black colour instead of Red. I have used React Native to build app for iOS and changing the colour like this works there, but somehow not on Android. I've checked the documentation but didn't see any mentions on limitation either. Is there a certain settings that I have to set first before being able to set text colour on Android?

I've tried stripping everything to just a basic class but still doesn't seem to work:

import React, { Component } from 'react';
import {
Text,
} from 'react-native';

export default class StartScreen extends Component {
constructor(props) {
super(props);
}

render() {
return (
<Text style={{color: '#F00'}}>TEST</Text>
);
}
}


Android version: 5.1
React-Native version: 0.46.1

EDIT:

It seems that React-Native page actually have a line that states:


Android Studio installs the latest Android SDK by default. Building a
React Native app with native code, however, requires the Android 6.0
(Marshmallow) SDK in particular


Since my device was running Android 5.1. It caused issues like this one.

source: https://facebook.github.io/react-native/docs/getting-started.html

Answer Source

Have you tried to change its android version ?

I worked on version android 6.0, your code is work..i think the problem on your version android.

enter image description here

Edit#1

I read on documentation this. They suggest to require the Android 6.0 (Marshmallow) when we use ReactNative.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download