Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get height and width of screen in react native

import { Dimensions } from 'react-native';

const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;

//publisher - Bathila Sanvidu Jayasundara - FullStack Developer
Comment

width 100% react-native

First, define Dimensions.

import { Dimensions } from "react-native";

var width = Dimensions.get('window').width; //full width
var height = Dimensions.get('window').height; //full height

then, change line1 style like below:

line1: {
    backgroundColor: '#FDD7E4',
    width: width,
},
Comment

width 100% react native

import { Dimensions } from 'react-native';

width: ${(Dimensions.get('window').width)}px;
Comment

Get React Native View width and height

import React from 'react'
import { View } from 'react-native'

export default function index() {
  const onLayout=(event)=> {
    const {x, y, height, width} = event.nativeEvent.layout;
    
  }
  return (
    <View onLayout={onLayout}>
      <OtherComponent />
    </View>
  )
}
Comment

how to take 100% width in react native

header : {
	height : 100,
  	backgroundColor: "favorite color",
    alignSelf: "stretch",
}
Comment

Get size of a View in React Native

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

export default class Comp extends Component {

  find_dimesions(layout){
    const {x, y, width, height} = layout;
    console.warn(x);
    console.warn(y);
    console.warn(width);
    console.warn(height);
  }
  render() {
    return (
      <View onLayout={(event) => { this.find_dimesions(event.nativeEvent.layout) }} style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.android.js
        </Text>
        <Text style={styles.instructions}>
          Double tap R on your keyboard to reload,{'
'}
          Shake or press menu button for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('Comp', () => Comp);
Comment

React Native Setting Height And Width

import React from 'react';
import { View } from 'react-native';

const Dimensions = () => {
  return (
 <View>
      <View style={{
        width: 50, height: 50, backgroundColor: 'powderblue'
      }} />
      <View style={{
        width: 100, height: 100, backgroundColor: 'skyblue'
      }} />
      <View style={{
        width: 150, height: 150, backgroundColor: 'steelblue'
      }} />
    </View>
   );
  };
export default Dimensions; 
      
Comment

how to set width 100 react native

line1:{
alignSelf: 'stretch',
}
Comment

react native get screen height and width

const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;
Comment

react native get screen height and width

import { Dimensions } from 'react-native';

const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;
Comment

react native height full

flex:1,
Comment

PREVIOUS NEXT
Code Example
Javascript :: There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally. 
Javascript :: prop type for ref in react js 
Javascript :: get result and write to file node 
Javascript :: jquery json object 
Javascript :: javascript date get nearest 15 minutes 
Javascript :: javascript replace all 
Javascript :: how to fetch the all input element id value 
Javascript :: onclick open link js 
Javascript :: check if input is a number javascript 
Javascript :: object iterate in javascript 
Javascript :: ... unicode 
Javascript :: jquery select div in div 
Javascript :: javascript parse a json string 
Javascript :: bootstrap js, jQuery, popper cdn 
Javascript :: push input value to array javascript 
Javascript :: regex for company name 
Javascript :: request body empty express 
Javascript :: get url params with js 
Javascript :: how to update kali linux on virtualbox 
Javascript :: install react native gifted charts 
Javascript :: javascript remove duplicated from Array 
Javascript :: react state hooks 
Javascript :: tabuada js 
Javascript :: jquery get all text inputs 
Javascript :: : Cannot set the body fields of a Request with content-type "application/json". 
Javascript :: remove matching element from two array javascript 
Javascript :: how to print hello world using js 
Javascript :: js sort numbers descending order 
Javascript :: ionic 3 alert 
Javascript :: angular production vs development mode 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =