마

레이아웃 연습 #1

· 2016-11-23 (수) 02:11:10 · 1828

https://g6ling.gitbooks.io/react-native-tutorial-korean/content/1-5ko.html 참조 

 

ff9cdf20f22e0f6aac1605ab7717088c_1479834414_7312.png

 

광고까지 하면 크게 5개로 나눠 집니다.

NavBar, User, ButtonGroup, Ads, Taps로..  가능하면 Fixed Height를 사용하지 말고, Flex를 사용해서 만들어 보세요..

 

*** 코드가 길어지니 에러가 나네요..  아래와 같이 만들어 봤습니다.

 

807e1408f3086de61be7726b302f5d2f_1479875168_5068.png

 

아래의 코드를 밑의 글의 링크에 카피 & 페이스트로 테스트 해 보세요

 

[code]

import React, { Component } from 'react';

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

 

class NavBar extends Component {

  render() {

    return (

      <View style={styles.navbar}>

        <Text style={styles.textColor}>더보기</Text>

      </View>

    )

  }

}

class User extends Component {

  render() {

    return (

      <View style={styles.user}>

      </View>

    )

  }

}

class ButtonGroup extends Component {

  render() {

    return (

      <View style={styles.buttongroup}>

 

      </View>

    )

  }

}

class Ads extends Component {

  render() {

    return (

      <View style={styles.ads}>

      </View>

    )

  }

}

class Taps extends Component {

  render() {

    return (

      <View style={styles.taps}>

 

      </View>

    )

  }

}

 

class gitbookTest extends Component {

  render() {

    return (

      <View style={styles.container}>

        <NavBar />

        <User />

        <ButtonGroup />

        <Ads />

        <Taps />

 

      </View>

    );

  }

}

 

 

const styles = StyleSheet.create({

  container: {

    flex: 1,

    flexDirection: 'column',

    justifyContent: 'space-between'

  },

  navbar: {

    height: 50,

    marginTop: 20,

    alignItems: 'center',

    justifyContent: 'center',

    backgroundColor: 'orangered',

  },

  textColor: {

    color: 'white',

    fontSize: 20

  },

  user: {

    flex: 2,

    backgroundColor: 'darkturquoise'

  },

  buttongroup: {

    marginTop: 40,

    flex: 3,

    backgroundColor: 'lightgreen',

  },

  ads: {

    flex: 1,

    backgroundColor: 'mediumpurple',

  },

  taps: {

    flex: 1,

    backgroundColor: 'blue'

  },

  rightBottom: {

    flex: 2,

    backgroundColor: 'yellow'

  }

 

});

AppRegistry.registerComponent('awesome', () => gitbookTest);

[/code]
 

|
댓글을 작성하시려면 로그인이 필요합니다.

앱개발

758건
+
분류 제목 글쓴이 날짜 조회
16-11-30 조회 1,850
16-11-30 조회 1,430
16-11-29 조회 1,331
16-11-29 조회 1,511
16-11-29 조회 1,521
16-11-28 조회 1,351
16-11-28 조회 1,312
16-11-28 조회 1,475
16-11-27 조회 2,039
16-11-27 조회 1,104
16-11-27 조회 1,062
16-11-26 조회 1,681
16-11-26 조회 1,388
16-11-26 조회 1,421
16-11-25 조회 1,148
16-11-25 조회 1,374
16-11-25 조회 1,339
16-11-24 조회 1,494
16-11-24 조회 1,328
16-11-24 조회 1,314
16-11-23 조회 1,290
16-11-23 조회 1,829
16-11-23 조회 1,296
16-11-22 조회 1,579
16-11-22 조회 1,424
16-11-22 조회 1,763
16-11-21 조회 1,735
16-11-21 조회 1,666
16-11-21 조회 2,396
16-11-20 조회 1,344