- 전체
- android studio
- Android SDK
- Android NDK
- Android ADK
- Android Etc. Lib.
- Android dalvik VM
- Android 보안
- PhoneGap
- AOSP 개발
- MIT App Inventor 2
- kivy (python)
- ionic framework
- Kotlin (코틀린)
- React Native
[안드로이드 강좌]6.레이아웃 종류/설명
2016.04.30 16:32
[안드로이드 강좌]6.레이아웃 종류/설명
| 레이아웃 종류 | 설명 |
| Linear Layout | -가장 기본적인 레이아웃 |
| -수직방향 또는 수평 방향으로,일렬로 위젯이나 뷰를 배치하는 레이아웃 | |
| Relative Layout | -기준이 되는 레이아웃과의 상대적인 위치를 기반으로 뷰나 위젯의 위치를 지정하는 레이아웃 |
| -간단하게 누구 밑에 누구,누구옆에 누구식으로 서로간의 위치 관계 지정 | |
| Frame Layout | -형태상으로 모든 레이아웃 중 가장 단순 |
| -차일드를 배치하는 규칙이 따로 없고 차일드는 프레임 좌상단에 표시 | |
| Table Layout | -표형식으로 차일드를 배치하는 레이아웃 |
| -가로,세로로 줄을 긋고 각 줄이 만나는 행과 열로 구성 | |
| -여러 개의 TableRow객체로 구성 하나의 행 |
레이아웃 인플레이션(전개,Layout Inflation)
-XML문서에 정의된 레이아웃과 차일드 뷰의 속성을 읽어 실제 뷰 객체를 생성하는 동작
-인플레이션의 핵심 메서드 : setContentView
-setContentView : XML문서의 리소스 ID를 전달받아 이 정보대로 객체를 생성하여 액티비티 내부에 채움
-특별한 것이 아니라 레이아웃의 정보대로 객체를 생성하고 속성 변경 메소드를 순서대로 후출하는것
-XML정보대로 뷰 하나를 생성해내는 것이므로 임의의 뷰 객체를 XML로 부터 얻을 수 있는 좋은 방법
<여러 레이아웃 중첩으로 만들어보기>
기본적인 소스의 내용은
[나홀로 개발자를 위한 안드로이드 프로그래밍의 모든 것]참조

|
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> |
본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 2 | Android : Keystore 정보확인 및 패스워드 변경 | 졸리운_곰 | 2017.03.23 | 235 |
| 1 |
넥서스5 USB to PC 연결 뒤 아무것도 안 보인다면
| 졸리운_곰 | 2016.04.18 | 732 |

