android 안드로이드 소스 - LinearLayout을 스크롤 가능하게 만드는 방법은 무엇입니까?
4
Answers
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
studio scroll xml
화면에 많은 항목이 있으며 사용자가 아래로 스크롤 할 수 있도록 스크롤 막대를 사용해야합니다. 그러나 스크롤이 보이지 않거나 작동하지 않습니다. LinearLayout
스크롤 바를 어떻게 추가 할 수 있습니까?
217 votes
android
이 작업은 <ScrollView>
태그를 사용하여 수행 할 수 있습니다. ScrollView의 경우 , 당신이 상기시켜야 할 한 가지는, ScrollView는 하나의 자식이 있어야합니다 .
전체 레이아웃을 스크롤 할 수있게하려면 상단에 <ScrollView>
를 추가하십시오. 아래 주어진 예를 확인하십시오.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Content here -->
</LinearLayout>
</ScrollView>
그러나 레이아웃의 일부를 스크롤 할 수있게하려면 해당 부분에 <ScrollView>
를 추가하십시오. 아래 주어진 예를 확인하십시오.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="400dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Content here -->
</LinearLayout>
</ScrollView>
</LinearLayout>
android1
215
<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"
android:orientation="vertical"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"`enter code here`>
<---------Content Here --------------->
</LinearLayout>
</ScrollView>
</LinearLayout>
android2
214
linearLayout에 atrribute를 추가 할 수 있습니다. android:scrollbars="vertical"
android3
213