UFO ET IT

Scrollview는 하나의 직계 자식 만 호스트 할 수 있습니다.

ufoet 2020. 12. 2. 22:17
반응형

Scrollview는 하나의 직계 자식 만 호스트 할 수 있습니다.


LinearLayout장치의 화면 높이를 쉽게 초과하는 결합 된 높이의 여러 s가 있습니다. 그래서 내 레이아웃을 스크롤 가능하게 만들기 위해를 추가하려고 시도 ScrollView했지만 불행히도 다음 오류가 발생합니다.

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"
android:orientation="vertical" >

    <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingTop="20dip">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 1"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q1_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 2"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q2_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 3"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q3_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 4"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q4_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 5"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q5_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
    <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 6"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q6_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 7"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q7_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 8"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q8_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 9"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q9_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 10"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q10_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 11"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q11_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 12"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q12_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 13"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q13_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 14"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q14_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 15"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q15_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 16"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q16_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 17"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q17_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 18"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q18_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 19"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q19_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>
</LinearLayout>
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Question 20"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/q20_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text=""
        android:gravity="center"/>

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Score:"
        android:paddingBottom="20dip"
        android:gravity="center" />
    <TextView
        android:id="@+id/final_score"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="0/5"
        android:gravity="center"/>
</LinearLayout>
    </LinearLayout>
        </ScrollView>

다른 LinearLayout 내부의 모든 자식을 wrap_content너비와 높이 및 세로 방향으로 래핑합니다 .

참고URL : https://stackoverflow.com/questions/16699772/scrollview-can-host-only-one-direct-child

반응형