아래 레이아웃 1,2,3의 풀 코드 > 앱개발

앱개발

아래 레이아웃 1,2,3의 풀 코드 정보

아래 레이아웃 1,2,3의 풀 코드

본문

아래에 올린 아이콘을 이용해서 만들어 본 최종 코드입니다. 아이폰 시뮬레이터에서는 안나와서 위의 링크에 아래 코드를 Copy & Paste를 해서 본 것입니다.

807e1408f3086de61be7726b302f5d2f_1479970554_3284.png


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

class NavBar extends Component {
  render() {
    return (
      <View style={styles.navbar}>
        <Text style={styles.textColor}>더보기</Text>
      </View>
    )
  }
}
class UserComment extends Component {
  render () {
    return (
      <View style={{flex:1, flexDirection: 'row', margin: 3, backgroundColor: 'aqua', justifyContent: 'space-between', }}>
        <View style={{flex:1,  margin: 2, minWidth: 20,justifyContent: 'center', alignItems: 'center'}}>
          <Image source={{uri: this.props.imagesrc}} />
        </View>
        <View style={{flex:2, justifyContent: 'center',  margin: 3}}>
          <Text style={{paddingLeft: 5}}>{this.props.name}</Text>
        </View>
      </View>
    )
  }
}
class User extends Component {
  render() {
    return (
      <View style={styles.user}>
        <View style={{flex:2, flexDirection: 'row', margin: 3, backgroundColor: 'antiquewhite', justifyContent: 'space-around'}}>
          <View style={{flex:1, margin: 3, backgroundColor: 'aqua'}}>
            <View style={{flex:1,  margin: 2, minWidth: 60, justifyContent: 'center', alignItems: 'center', borderWidth: 1, borderRadius: 50, backgroundColor: 'white'}}>
            </View>
          </View>
          <View style={{flex:3, flexDirection: 'column', margin: 3, backgroundColor: 'aqua', justifyContent: 'flex-start'}}>
            <Text style={{ fontSize: 20, fontWeight: 'bold'}}>은애악</Text>
            <Text>강철 / g6lingp</Text>
            <Text>서울대 16학번</Text>
          </View>
        </View>
        <View style={{ flex:1, flexDirection: 'row', margin: 3, backgroundColor: 'bisque', justifyContent: 'space-around'}}>
          <UserComment imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950536_4407.png' name='내가 쓴 글'/>
          <UserComment imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950742_1528.png' name='댓글 단 글'/>
          <UserComment imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950793_3841.png' name='스크랩'/>
        </View>
      </View>
    )
  }
}
class Button extends Component {
  render () {
    return (
      <View style={{flex: 1, flexDirection: 'column', borderWidth: 0.5}}>
        <View style={{flex:2,  margin: 2, minWidth: 20, justifyContent: 'center', alignItems: 'center'}}>
          <Image source={{uri: this.props.imagesrc}} />
        </View>
        <View style ={{flex:1, justifyContent: 'center', alignItems: 'center'}}>
          <Text>{this.props.name}</Text>
        </View>
      </View>
    )
  }
}
class ButtonGroup extends Component {
  render() {
    return (
      <View style={styles.buttongroup}>
        <View style={{flex:1, flexDirection: 'row', justifyContent: 'space-between'}}>
          <Button imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950159_8211.png' name='강의평가'/>
          <Button imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950181_0548.png' name='학점계산기'/>
        </View>
        <View style={{flex:1, flexDirection: 'row', justifyContent: 'space-between'}}>
          <Button imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950160_3432.png' name='공지사항'/>
        </View>
      </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: 10,
    flex: 3,
    backgroundColor: 'lightgreen',
  },
  ads: {
    flex: 1,
    backgroundColor: 'lightblue',
  },
  taps: {
    flex: 1,
    backgroundColor: 'mediumpurple',
    flexDirection: 'row'
  }

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

 

공감
0

댓글 0개

전체 756 |RSS
앱개발 내용 검색

회원로그인

진행중 포인트경매

  1. 참여6 회 시작24.04.25 20:23 종료24.05.02 20:23
(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT