1. ScrollView


스크롤뷰는 말 그대로 스크롤 기능이 있는 뷰이다.

스크롤뷰는 화면에 보이는 공간을 넘어갔을 때 자동으로 스크롤을 만들어 준다.



2. 결과 화면




3. activity_main.xml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.tistory.qlyh8.pracitice.MainActivity"
    android:layout_margin="10dp">
 
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
 
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="80sp"
            android:text="Hello world!\nHello world!\nHello world!\n"
            />
    </ScrollView>
</LinearLayout>
 
cs





출처: https://www.edwith.org/boostcourse-android/lecture/20484/

1. Table Layout


테이블 레이아웃은 격자 모양으로 뷰를 배치할 때 사용한다.

리니어 레이아웃 안에 리니어 레이아웃을 넣는 방식을 사용해도 격자 모양을 만들 수 있지만 테이블 레이아웃을 사용하면 좀 더 쉽게 만들 수 있다.


테이블 레이아웃에서 각각의 행은 <TableRow> 태그를 이용해 추가할 수 있다.

그리고 그 안에 몇 개의 뷰를 추가하는가에 따라 열의 개수가 결정된다.

여러 개의 <TableRow>가 추가될 수 있고 각각의 <TableRow> 안에는 여러 개의 뷰가 들어갈 수 있는 구조로 되어 있다.



2. 결과 화면




3. activity_main.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
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.tistory.qlyh8.pracitice.MainActivity"
    android:stretchColumns="0,1,2"
    android:layout_margin="10dp">
 
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="이름 : " />
 
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_span="2"/>
    </TableRow>
 
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="아니오"
            android:layout_column="1"/>
 
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="예"
            android:layout_column="2"/>
    </TableRow>
 
 
</TableLayout>
 
cs





출처: https://www.edwith.org/boostcourse-android/lecture/17050/

'Android' 카테고리의 다른 글

Event (이벤트)  (0) 2018.04.28
ScrollView (스크롤뷰)  (0) 2018.04.28
Drawable (드로어블) - Shape Drawable  (0) 2018.04.28
Drawable (드로어블) - StateListDrawable  (0) 2018.04.27
Drawable (드로어블)  (0) 2018.04.27

1. Shape Drawable


Shape Drawable을 이용해 XML로 도형을 그릴 수 있다.

shape 속성으로는 rectangle(직사각형), oval(타원), line(선), ring(고리)이 있다.


- <stroke>태그: 테두리 선 설정

- <width> 태그: 선의 굵기 설정

- <color> 태그: 선의 색상 설정

- <solid> 태그: 도형의 안쪽 설정



2. 실행 화면





3. drawable/rectangle.xml


1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
 
    <size android:width="200dp" android:height="120dp"/>
    <stroke android:width="2dp" android:color="#000000"/>
    <solid android:color="#FFEF60"/>
    <padding android:bottom="1dp"/>
</shape>
cs


4. drawable/gradient.xml


1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 
    <gradient
        android:startColor="#FF5500"
        android:centerColor="#00FF55"
        android:endColor="#0055FF"
        android:angle="90"
        android:centerY="0.5"/>
 
    <corners android:radius="2dp"/>
 
</shape>
cs


5. drawable/layer_list.xml


<layer-list> 태그를 이용해 여러 그래픽을 하나의 XML 파일에 넣을 수 있다.

<item> 태그가 여러 개 들어갈 수 있으며, <item> 태그 안에는 <shape> 태그가 들어갈 수 있어 각각의 도형으로 정의할 수 있다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 
    <item>
        <shape android:shape="rectangle">
            <stroke android:width="4dp" android:color="#A0A0F0"/>
            <solid android:color="#00000000"/>
        </shape>
    </item>
    <item android:top="4dp" android:bottom="4dp"
        android:right="4dp" android:left="4dp">
        <shape android:shape="rectangle">
            <stroke android:width="5dp" android:color="#440000"/>
            <solid android:color="#00000000"/>
        </shape>
    </item>
</layer-list>
cs



6. activity_main.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
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.tistory.qlyh8.pracitice.MainActivity"
    android:orientation="vertical"
    android:layout_margin="10dp">
 
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/rectangle"
        android:layout_weight="1"/>
 
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/gradient"
        android:layout_weight="1"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/layer_list"
        android:text="Button"
        android:layout_gravity="center" />
 
</LinearLayout>
 
cs





출처: https://www.edwith.org/boostcourse-android/lecture/20421/

'Android' 카테고리의 다른 글

ScrollView (스크롤뷰)  (0) 2018.04.28
Table Layout (테이블 레이아웃)  (0) 2018.04.28
Drawable (드로어블) - StateListDrawable  (0) 2018.04.27
Drawable (드로어블)  (0) 2018.04.27
adMob - (4) 전면 광고 달기  (0) 2018.03.03

+ Recent posts