Scroll View - 뷰를 위,아래로 스크롤 할 수 있게 만들어주는 기능
Scroll View 사용
1. 하나의 뷰만 스크롤 할 경우
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1. 동해 물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
2. 남산 위에 저 소나무, 철갑을 두른 듯 바람 서리 불변함은 우리 기상일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
3. 가을 하늘 공활한데 높고 구름 없이 밝은 달은 우리 가슴 일편단심일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
4. 이 기상과 이 맘으로 충성을 다하여 괴로우나 즐거우나 나라 사랑하세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세. "
android:textSize="50dp"
/>
</ScrollView>
2. 하나 이상의 뷰를 스크롤 할 경우
ㄴ 스크롤 뷰에는 한개의 뷰만 존재할 수 있기 때문에 여러가지의 뷰를 사용하기 위해선 하나의 레이이아웃으로 묶어서 사용한다
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1. 동해 물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
2. 남산 위에 저 소나무, 철갑을 두른 듯 바람 서리 불변함은 우리 기상일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
3. 가을 하늘 공활한데 높고 구름 없이 밝은 달은 우리 가슴 일편단심일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
4. 이 기상과 이 맘으로 충성을 다하여 괴로우나 즐거우나 나라 사랑하세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세. "
android:textSize="30dp"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:text="버튼"/>
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@mipmap/ic_launcher"
android:layout_gravity="center"/>
</LinearLayout>
</ScrollView>
Horizontal Scroll View - 뷰를 좌, 우로 스크롤 할 수 있게 만들어주는 기능
Horizontal Scroll View 사용
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1. 동해 물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
2. 남산 위에 저 소나무, 철갑을 두른 듯 바람 서리 불변함은 우리 기상일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
3. 가을 하늘 공활한데 높고 구름 없이 밝은 달은 우리 가슴 일편단심일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세.
4. 이 기상과 이 맘으로 충성을 다하여 괴로우나 즐거우나 나라 사랑하세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세. "
android:textSize="30dp"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:text="버튼"/>
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@mipmap/ic_launcher"
android:layout_gravity="center"/>
</LinearLayout>
</HorizontalScrollView>
'Android' 카테고리의 다른 글
Android] 액티비티를 팝업 창 모드로 출력하기 (1) | 2022.05.07 |
---|---|
Android] Dialog를 사용하여 알림 창 띄우기 (0) | 2022.05.07 |
Android] Shared Preferences를 이용한 간단한 회원 가입 (0) | 2022.04.05 |
Android] 값을 입력 받아서 Gson 사용하기 (0) | 2022.04.01 |
Android] Gson의 정의 및 사용 방법 (0) | 2022.03.30 |