[안드로이드 강좌]6.레이아웃 종류/설명

 

 

 

레이아웃 종류 설명
Linear Layout -가장 기본적인 레이아웃
-수직방향 또는 수평 방향으로,일렬로 위젯이나 뷰를 배치하는 레이아웃
Relative Layout -기준이 되는 레이아웃과의 상대적인 위치를 기반으로 뷰나 위젯의 위치를 지정하는 레이아웃
-간단하게 누구 밑에 누구,누구옆에 누구식으로 서로간의 위치 관계 지정
Frame Layout -형태상으로 모든 레이아웃 중 가장 단순
-차일드를 배치하는 규칙이 따로 없고 차일드는 프레임 좌상단에 표시
Table Layout -표형식으로 차일드를 배치하는 레이아웃
-가로,세로로 줄을 긋고 각 줄이 만나는 행과 열로 구성
-여러 개의 TableRow객체로 구성 하나의 행

 

 레이아웃 인플레이션(전개,Layout Inflation)

-XML문서에 정의된 레이아웃과 차일드 뷰의 속성을 읽어 실제 객체를 생성하는 동작
-인플레이션의 핵심 메서드 : setContentView
-setContentView : XML문서의 리소스 ID를 전달받아 이 정보대로 객체를 생성하여 액티비티 내부에 채움
-특별한 것이 아니라 레이아웃의 정보대로 객체를 생성하고 속성 변경 메소드를 순서대로 후출하는것
-XML정보대로 하나를 생성해내는 것이므로 임의의 객체를 XML로 부터 얻을 수 있는 좋은 방법

 

<여러 레이아웃 중첩으로 만들어보기>

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

기본적인 소스의 내용은

[나홀로 개발자를 위한 안드로이드 프로그래밍의 모든 것]참조

25750D4E5294A1822BF60A

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!--?xml version="1.0" encoding="utf-8"?-->
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff">
<linearlayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnpage1" android:text="EXAM 111111">
</button><button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnpage2" android:text="EXAM 2">
</button><button unselectable="on" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnpage3" android:text="EXAM 3">
 
<framelayout unselectable="on" android:layout_width="fill_parent" android:layout_height="fill_parent">
<linearlayout unselectable="on" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffff00" android:id="@+id/page1">
    <textview unselectable="on" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="1 페이지" android:textcolor="#000000">
    <imageview unselectable="on" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ass101">  
</imageview></textview></linearlayout>
<relativelayout unselectable="on" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#00ff00" android:id="@+id/page2" android:visibility="invisible">
<edittext unselectable="on" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="2 페이지" android:layout_alignparentright="true">
</edittext></relativelayout></framelayout></button><button unselectable="on" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="확인" android:layout_alignparentbottom="true">
 
<tablelayout unselectable="on" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#0000ff" android:id="@+id/page3" android:visibility="invisible">
    <tablerow unselectable="on">
        <textview unselectable="on" android:text="소" android:textsize="30sp" android:padding="10dip">
        <textview unselectable="on" android:text="닭" android:textsize="30sp" android:padding="10dip">
        <textview unselectable="on" android:text="돼지" android:textsize="30sp" android:padding="10dip">
    </textview></textview></textview></tablerow>
    <tablerow unselectable="on">
        <textview unselectable="on" android:text="3" android:textsize="30sp" android:padding="10dip">
        <textview unselectable="on" android:text="5" android:textsize="30sp" android:padding="10dip">
        <textview unselectable="on" android:text="10" android:textsize="30sp" android:padding="10dip">
    </textview></textview></textview></tablerow>
</tablelayout>
 
 
<pre></pre>
 
<p><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(247,247,247); TEXT-INDENT: 0px; LETTER-SPACING: -1px; DISPLAY: inline !important; FONT: bold 20px/24px dotum; WHITE-SPACE: normal; FLOAT: none; COLOR: rgb(1,114,201); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px" unselectable="on">자바소스</span></p>
<pre class="brush:java;">public class DupLayoutActivity extends Activity {
 
    View mPage1, mPage2, mPage3;
     
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        mPage1 = findViewById(R.id.page1);
        mPage2 = findViewById(R.id.page2);
        mPage3 = findViewById(R.id.page3);
 
        findViewById(R.id.btnpage1).setOnClickListener(mClickListener);
        findViewById(R.id.btnpage2).setOnClickListener(mClickListener);
        findViewById(R.id.btnpage3).setOnClickListener(mClickListener);
    }
 
    Button.OnClickListener mClickListener = new Button.OnClickListener() {
        public void onClick(View v) {
            mPage1.setVisibility(View.INVISIBLE);
            mPage2.setVisibility(View.INVISIBLE);
            mPage3.setVisibility(View.INVISIBLE);
             
            switch (v.getId()) {
            case R.id.btnpage1:
                mPage1.setVisibility(View.VISIBLE);
                Log.d("TEST","BTN1 click");
                //mPage1.setBackgroundColor(Color.BLUE);
                break;
            case R.id.btnpage2:
                mPage2.setVisibility(View.VISIBLE);
                mPage2.setBackgroundColor(Color.BLUE);
                break;
            case R.id.btnpage3:
                mPage3.setVisibility(View.VISIBLE);
                break;
            }
        }
    };
 
}
</pre></button></linearlayout></linearlayout>

[출처] http://daehyub71.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EA%B0%95%EC%A2%8C6%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83-%EC%A2%85%EB%A5%98%EC%84%A4%EB%AA%85

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
73 Android Studio 2.2에서 Layout Preview 한글 깨짐 현상 해결 방법 file 졸리운_곰 2017.03.08 568
72 윈도우즈에서 IntelliJ IDEA + android 개발환경 만들기 file 졸리운_곰 2016.12.05 488
71 코틀린 Kotlin (코틀린) 레퍼런스 문서 한글판 file 졸리운_곰 2016.12.04 1683
70 안드로이드를 위한 Swift - Kotlin을 아시나요? 졸리운_곰 2016.12.04 624
69 Ionic Framework로 만화 사이트 어플 만들기 #3 file 졸리운_곰 2016.07.31 273
68 Ionic Framework로 만화 사이트 어플 만들기 #2 file 졸리운_곰 2016.07.31 570
67 Ionic Framework로 만화 사이트 어플 만들기 #1 file 졸리운_곰 2016.07.31 379
66 Ionic을 이용한 iOS, Android 하이브리드 앱 개발 사례 file 졸리운_곰 2016.07.31 550
65 Ionic Framework를 이용하여 하이브리드앱 개발하기 file 졸리운_곰 2016.07.31 284
64 Build a mobile app with Ionic + WordPress file 졸리운_곰 2016.06.06 362
63 Create a Mobile Application Using WordPress, Ionic, and AngularJS file 졸리운_곰 2016.06.06 10185
62 Ionic Framework를 이용하여 하이브리드앱 개발하기 file 졸리운_곰 2016.06.06 426
61 Creating a Custom TinyWebDB Service 졸리운_곰 2016.05.18 201
60 TinyDB is a lightweight document oriented database file 졸리운_곰 2016.05.16 270
59 구글 앱엔진에 의한 소형웹데이터베이스의 접속방법 tinywebdb file 졸리운_곰 2016.05.15 547
58 단말기 내부에 폴더 및 txt파일 생성하기 file 졸리운_곰 2016.05.01 171
57 wifi 연결시 알림 android source 졸리운_곰 2016.05.01 250
56 How to use Broadcast Receiver in Android – Send and Receive SMS file 졸리운_곰 2016.05.01 292
» [안드로이드 강좌]6.레이아웃 종류/설명 file 졸리운_곰 2016.04.30 228
54 [Android] Layout XML - layout_weight file 졸리운_곰 2016.04.30 23630
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED