Programing

레이아웃을 아래로 스크롤하려면 어떻게해야합니까?

lottogame 2020. 10. 18. 08:22
반응형

레이아웃을 아래로 스크롤하려면 어떻게해야합니까?


화면을 아래로 스크롤하여 "Replied By :"섹션의 데이터를 볼 수 없습니다. 레이아웃을 스크롤 가능하게 만들려면 어떻게해야합니까?

대체 텍스트


모든 것을 다음과 같이 감싸십시오 ScrollView.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <!-- Here you put the rest of your current view-->
</ScrollView>

David Hedlund가 말했듯이, ScrollView하나의 항목 만 포함 할 수 있습니다. 따라서 다음과 같은 것이 있다면 :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <!-- bla bla bla-->
</LinearLayout>

다음으로 변경해야합니다.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
        <!-- bla bla bla-->
    </LinearLayout>
</ScrollView>

상대 레이아웃과 함께 스크롤보기를 사용하는 경우 :

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="@drawable/background_image"
    >

    <!-- Bla Bla Bla i.e. Your Textviews/Buttons etc. -->
    </RelativeLayout>
</ScrollView>

모든 것을 ScrollView 안에 감싸십시오.

<?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="match_parent"
    tools:context="com.ruatech.sanikamal.justjava.MainActivity">
<!-- Here you put the rest of your current view-->
</ScrollView>

위에 적힌대로 했는데도 스크롤이 안 나오면 .....

을 설정 android:layout_height="250dp"하거나 말할 수 xdp어디에 x어떤 수치 값이 될 수 있습니다.

참고 URL : https://stackoverflow.com/questions/3819189/how-to-make-my-layout-able-to-scroll-down

반응형