2012-08-26 25 views
6

मैं एंड्रॉइड डिवाइस के लिए एक ऐप बना रहा हूं और मैं लाइनरलाइट के अंदर स्क्रॉलव्यू देखने की कोशिश कर रहा हूं लेकिन जब मैं ऐसा करने की कोशिश करता हूं तो स्क्रॉलव्यू स्क्रॉलव्यू के बाद सभी जगहों और तत्वों को लेता है LinearLayout disapear में। यदि scrollview "पूर्ण" है
http://kakko76.free.fr/scroll2.jpg
:एंड्रॉइड: लंबवत रैखिकलाइट में स्क्रॉल व्यू

उदाहरण के लिए:
scrollview यदि नहीं "पूर्ण" है
http://kakko76.free.fr/scroll1.png

आप बटन गायब देख सकते हैं ...

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_marginLeft="50dp" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:orientation="vertical" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:background="@drawable/linearlayoutbackground" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/nom_des_joueurs" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_marginBottom="30dp" /> 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:id="@+id/llPlayersName" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      > 

     </LinearLayout> 

    </ScrollView> 

    <Button 
     android:id="@+id/okPlayersName" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/ok" 
     android:background="@drawable/backgroundbutton" 
     android:layout_marginTop="30dp" /> 
</LinearLayout> 

बाद मैं लीनिया में तत्वों को जोड़ने: यहाँ इस गतिविधि का कोड है RLayout जो स्क्रॉलव्यू में हैं।
कोई समाधान?
धन्यवाद।

उत्तर

9

निम्नलिखित का प्रयास करें:

android:layout_height="0dp" 
android:layout_weight="1" 

यह आपके scrollview बताता अन्य तत्वों के कब्जे में नहीं सभी शेष अंतरिक्ष लेने के लिए।

+1

एक ही समय में एक ही समाधान लिख रहा था :-P आप तेजी से थे .. –

+0

आप इसे के काम की सराहना करते :) – kakko76

1

आप अपनी ऊंचाई के रूप में android:layout_height="wrap_content" था। इसका मतलब है कि ऊंचाई इसके अंदर की सामग्री जितनी अधिक है। यदि आप इसे पूरी जगह नहीं लेना चाहते हैं तो आप इसे वजन दे सकते हैं (ऊपर दिए गए उत्तर की तरह) या आप डीपी के साथ अपना हाइट सेट कर सकते हैं। उदाहरण के लिए:

<LinearLayout 
android:id="@+id/linearLayout1" 
android:layout_width="fill_parent" 
android:layout_marginLeft="50dp" 
android:layout_height="wrap_content" 
android:layout_centerHorizontal="true" 
android:layout_centerVertical="true" 
android:orientation="vertical" 
android:focusable="true" 
android:focusableInTouchMode="true" 
android:background="@drawable/linearlayoutbackground" 
android:weightSum="1.5" > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:layout_weight = "0.2" 
    android:text="@string/nom_des_joueurs" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:layout_marginBottom="30dp" /> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight = "1"> 

    <LinearLayout 
     android:id="@+id/llPlayersName" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     > 

    </LinearLayout> 

</ScrollView> 

<Button 
    android:id="@+id/okPlayersName" 
    android:layout_width="match_parent" 
    android:layout_height="0" 
    android:layout_weight = "0.3"> 
    android:text="@string/ok" 
    android:background="@drawable/backgroundbutton" 
    android:layout_marginTop="30dp" /> 

के रूप में आप देख सकते हैं मैं एक "राशि" और अपने बच्चों के सभी दिया जाता है वजन रेखीय लेआउट दे दी है। क्या यह स्पष्ट है? क्या आपको इसकी आवश्यकता है?

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