Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change text size according to screen react native

import { Dimensions, Platform, PixelRatio } from 'react-native';

const {
       width: SCREEN_WIDTH,
       height: SCREEN_HEIGHT,
     } = Dimensions.get('window');

     // based on iphone 5s's scale
     const scale = SCREEN_WIDTH / 320   ;

  export function actuatedNormalize(size) {
  const newSize = size * scale 
   if (Platform.OS === 'ios') {
    return Math.round(PixelRatio.roundToNearestPixel(newSize))
   } else {
     return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2
   }
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: get the text of a tag 
Javascript :: fuse.js npm 
Javascript :: javascript regex reference 
Javascript :: jquery change button click function 
Javascript :: javascript file exists check 
Javascript :: save image jpg javascript 
Javascript :: js remove first element from array 
Javascript :: chart js in angular 13 
Javascript :: javascript json stringify indented 
Javascript :: create a json object in javascript 
Javascript :: can promise is going to be handle asynchronously 
Javascript :: create react app command 
Javascript :: string to capitalize javascript 
Javascript :: Create MD5 hash with Node.js 
Javascript :: Mars Exploration problem in js 
Javascript :: tailwind content for nextjs 
Javascript :: how to compare elements in an array 
Javascript :: socket io emit to socket id 
Javascript :: how to insert an item into an array at a specific index javascript 
Javascript :: add checkbox dynamically in javascript 
Javascript :: javascript datetime format 
Javascript :: how to add number in string in javascript 
Javascript :: memory leak in javascript 
Javascript :: how to hide ascending descending icons in datatable js 
Javascript :: javascript sort map by value 
Javascript :: store images in mongoose 
Javascript :: random positive or negative javascript 
Javascript :: Select all elements with the same tag 
Javascript :: javascript 2 return values 
Javascript :: add one file to another in ejs 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =