44

होस्ट कर सकते हैं मैं एक संयुक्त ऊंचाई है कि आसानी से एक डिवाइस की स्क्रीन ऊंचाई से अधिक है के साथ कई LinearLayout रों है। तो क्रम में मेरी लेआउट स्क्रॉल बनाने के लिए, मैं एक ScrollView में जोड़ने की कोशिश की, लेकिन दुर्भाग्य से मैं निम्नलिखित त्रुटि मिलती है:scrollview केवल एक प्रत्यक्ष बच्चे

Scrollview can host only one direct child

मैं कुछ शोध किया, लेकिन वास्तव में यह कैसे हल करने के लिए का मतलब नहीं कर सकता है, यहां तक ​​कि कुछ समाधान पढ़ने के बाद। मैंने कुछ बदलावों की कोशिश की, लेकिन अब तक मेरे लिए कुछ भी काम नहीं किया। कोई मदद?

<?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> 

उत्तर

137

लपेटें सभी चौड़ाई और ऊंचाई दोनों के साथ ही खड़ी उन्मुखीकरण के लिए wrap_content के साथ एक और LinearLayout के अंदर बच्चों।

+0

यह जाने के लिए एक सही तरीका है। –

+0

आपको बहुत बहुत धन्यवाद! क्या आप मेरा एक और सवाल देखने में सक्षम होंगे? [कड़ी] (http://stackoverflow.com/questions/16679518/cant-save-audio-to-phone-using-media-player-in-eclipse) – user2407147

+3

मैं अपने अन्य प्रश्न का उत्तर दिया, मत भूलना जवाब स्वीकार करने के लिए बड़ी जांच के साथ हम जानते हैं कि हमने आपके प्रश्न का उत्तर दिया है। –

संबंधित मुद्दे