Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- node.js
- flutter
- CrossAxisAlignment
- Row
- ListTile
- Flutter 강좌
- Flutter Tutorial
- FutureBuilder
- Flutter Example
- AppBar
- MainAxisAlignment
- sqlite
- Scaffold
- Cached Image
- HTTP
- 반석천
- Image.network
- ListView.builder
- WillPopScope
- listview
- Flutter 앱 배포
- InkWell
- navigator
- Networking
- Column Widget
- Flutter 예제
- Load Image
- Hello World
- Row Widget
- Snackbar
Archives
- Today
- Total
꿈꾸는 시스템 디자이너
레이아웃 인플레이션(Layout Inflation) 본문
하나의 XML 레이아웃을 Activity에 매핑하여 이용하는 앱의 경우 정적인 화면 구성을 가지게 되는데, 동적인 화면구성을 위해서는 레이아웃 인플레이션(Layout Inflation) 기법을 이용한다.
- 레이아웃의 구성을 조각 조각으로 나누어 준비하고, 그때 그때 마다 원하는 조각들로 화면을 재구성할 수 있다.
<사용법>
1단계: 레이아웃 인플레이터 생성
아래와 같은 세가지 방법으로 인플레이터를 생성할 수 있다.
LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = this.getLayoutInflater();
LayoutInflater inflater = LayoutInflater.from(this);
LayoutInflater inflater = this.getLayoutInflater();
LayoutInflater inflater = LayoutInflater.from(this);
2단계: 원하는 뷰나 레이아웃들을 읽어 객채화
아래와 같은 방식으로 화면의 구성들을 객채화 할 수 있다.
ViewGroup MainLayout = inflater1.inflate(R.layout.main);
ViewGroup SubTitle = inflater1.inflate(R.layout.sub_title_layout);
View row = inflater1.inflate(R.layout.row, null);
ViewGroup SubTitle = inflater1.inflate(R.layout.sub_title_layout);
View row = inflater1.inflate(R.layout.row, null);
3단계: 계층구조 생성(옵셥)
MainLayout에 SubTile을 넣고 그 아래 row를 넣는 예제이다.
MainLayout.addView(SubTitle);
MainLayout.addView(row,2);
MainLayout.addView(row,2);
4단계: 화면에 출력
setContentView()나 setView()를 호출하여 화면에 출력함
'Development > Android' 카테고리의 다른 글
TabActivity 구성 방법(xml 레이아웃 파일 이용) (0) | 2012.04.04 |
---|---|
TabActivity 구성 방법(동적 방법) (0) | 2012.04.04 |
기본적인 View 사용법 3 (0) | 2012.04.03 |
기본적인 View 사용법 2 (0) | 2012.04.03 |
기본적인 View 사용법 1 (0) | 2012.02.02 |
Comments