“Ukuran font responsif bereaksi asli” Kode Jawaban

bereaksi font penskalaan asli

<Text
    numberOfLines={1}// add this
    adjustsFontSizeToFit// add this
    style={{textAlign:'center',fontSize:30}}
  >
Alexandre Dao

bereaksi font responsif asli

import { Dimensions } from 'react-native';

const { width, **fontScale** } = Dimensions.get("window");

const styles = StyleSheet.create({
    fontSize: idleFontSize / **fontScale**,
});
Crazy Capybara

Ubah Ukuran Teks Menurut layar bereaksi asli

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
   }
  }
Xenophobic Xenomorph

Ukuran font responsif bereaksi asli

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

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

export function normalize(size, multiplier = 2) {
  const scale = (width / height) * multiplier;

  const newSize = size * scale;

  return Math.round(PixelRatio.roundToNearestPixel(newSize));
}
Helpful Hamster

Jawaban yang mirip dengan “Ukuran font responsif bereaksi asli”

Pertanyaan yang mirip dengan “Ukuran font responsif bereaksi asli”

Lebih banyak jawaban terkait untuk “Ukuran font responsif bereaksi asli” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya