Tools/Android Studio

[ Android Studio ] 안드로이드 스크롤뷰 (ScrollView)

리신 2021. 10. 23. 02:17
반응형

스크롤 뷰란?

말 그대로 많은 뷰들이 있어서 한 화면에 다 보여주지 못할 때 스크롤 뷰를 사용하여 스크롤을 할 수 있게 해주는 뷰이다.

🔔스크롤 뷰는 오직 하나의 뷰만 감쌀 수 있다.

[scrollview.xml]

<?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="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@color/cancle_red" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@color/yello" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@color/sky_sumin" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@color/orange_june" />
    </LinearLayout>
</ScrollView>

 

위 코드의 디자인

 

설명 :  스크롤뷰는 하나의 뷰만 포함한다는 특성 때문에 TextView뷰들을

             LinearLayout으로 한번 감싸서 하나의 뷰로 나타 냈다.

 

 

수평으로 스크롤하는 방법이 궁금하시다면❗❕

2021.10.23 - [Tools/Android Studio] - [ Android Studio ] 안드로이드 수평 스크롤뷰 (HorizontalScrollView)

 

[ Android Studio ] 안드로이드 수평 스크롤뷰 (HorizontalScrollView)

수평 스크롤뷰(HorizontalScrollView)는 스크롤뷰와 거의 같다 💡하지만 다른점이 있음 스크롤뷰 :  수직 방향으로 스크롤 가능 수평 스크롤뷰  :  수평 방향으로 스크롤 가능 ❕❗수평 스크롤뷰도

dev-cini.tistory.com

 

반응형