Advertisement
Felanpro

React Native (flexBasis, flexGrow, flexShrink)

May 15th, 2023
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import { StatusBar } from 'expo-status-bar';
  2. import { Dimensions, useWindowDimensions, StyleSheet, Text, View, TouchableWithoutFeedback, TouchableOpacity, TouchableHighlight, Alert, Image, SafeAreaView, Button } from 'react-native';
  3. import { useDeviceOrientation } from '@react-native-community/hooks';
  4.  
  5. export default function App() {
  6.  
  7. return (
  8. <View
  9. style={{
  10. backgroundColor: "#fff",
  11. flex: 1,
  12. flexDirection: "row", // horizontal
  13. justifyContent: "center", // primary axis
  14. alignItems: "center", // secondary axis
  15. alignContent: "center",
  16.  
  17. /**
  18. * Press Ctrl + Space to see for example what values flexDirection can be assigned
  19. */
  20. }}
  21. >
  22.  
  23. <View
  24. style={{
  25. backgroundColor: "dodgerblue",
  26. //flexBasis: 100, // can be equivalent to width or height
  27. flexShrink: 1,
  28. width: 300,
  29. height: 100,
  30. }}
  31. />
  32.  
  33. <View
  34. style={{
  35. backgroundColor: "gold",
  36. width: 100,
  37. height: 100
  38. }}
  39. />
  40.  
  41. <View
  42. style={{
  43. backgroundColor: "tomato",
  44. width: 100,
  45. height: 100
  46. }}
  47. />
  48.  
  49. </View>
  50. );
  51. }
  52.  
  53. const containerStyle = {backgroundColor: "orange"};
  54.  
  55. const styles = StyleSheet.create({
  56. container: {
  57. flex: 1,
  58. backgroundColor: 'orange'
  59. },
  60. });
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement