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

how to set width 100 react native

line1:{
alignSelf: 'stretch',
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: string repeat javascript 
Javascript :: anagram checker javascript 
Javascript :: js cheat sheet 
Javascript :: fetch request 
Javascript :: farewell discord.js 
Javascript :: simple js drawing program 
Javascript :: chai test throw error 
Javascript :: js array map 
Javascript :: upload files with angular 
Javascript :: move element to the top of list javascript 
Javascript :: next auth session callback 
Javascript :: faker js 
Javascript :: how to see if user on phone 
Javascript :: extract content from string html 
Javascript :: queryselectorall example 
Javascript :: array concat in javascript 
Javascript :: How to initialize select2 dynamically 
Javascript :: react bootstrap button 
Javascript :: replace is not working in javascript 
Javascript :: JS how to determine if page was cached 
Javascript :: javascript loop through an array backwards 
Javascript :: get server side props 
Javascript :: how to count the rows of gridview in asp.net using jquery 
Javascript :: navlink 
Javascript :: Start Express Properly 
Javascript :: file_get_contents in javascript 
Javascript :: change url angular 
Javascript :: hello world in javascript 
Javascript :: unix to time in javascript 
Javascript :: string match 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =