2012-02-17 12 views
31

मैं इस लागू करना चाहते हैं: एक scrollview कि कई तत्वों (ImageViews, TextViews, EditTexts आदि) शामिल हैं और फिर scrollview के बाद कुछ बटन (जो कस्टम ImageViews हैं) हमेशा बिल्कुल पर दिखाई देते हैं कि स्क्रीन के नीचे।एंड्रॉयड scrollview और स्क्रीन के नीचे स्थित बटन

यदि मैं एंड्रॉइड का उपयोग करता हूं: fillViewport = "true" विशेषता, तो यदि स्क्रीन आकार में फिट करने के लिए स्क्रॉलव्यू के तत्व बहुत बड़े हैं तो बटन अदृश्य हो जाते हैं। अगर मैं एंड्रॉयड का उपयोग करें: जब स्क्रीन बड़ा है और यह फिट कर सकते हैं (मैं बटन एक छोटा सा प्रतिशत, लगभग 10% ले जाना चाहते हैं) वजन = 1 विशेषता तो scrollview स्क्रीन के केवल 50% हो जाता है। अगर मैं एंड्रॉइड सेट करता हूं: वजन को बड़े मानों पर तो बटन बहुत छोटे दिखाई देते हैं।

कृपया मदद करें! हो सकता है कि यह कुछ आसान है जिसे मैंने अनदेखा किया लेकिन मैं घंटों तक अपने सिर पर टक्कर लगी हूं! क्योंकि आप इसे एक रेखीय लेआउट पर है, तो रेखीय लेआउट फिट स्क्रीन में डाल

+0

लेआउट फ़ाइल –

उत्तर

72

बस बनाई और इसका परीक्षण किया। ऐसा लगता है कि आप चाहते हैं।

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

    <LinearLayout 
      android:id="@+id/buttons" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:gravity="center" 
      android:layout_alignParentBottom="true"> 
     <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Custom Button1"/> 
     <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Custom Button2"/> 
    </LinearLayout> 

    <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@id/buttons"> 
     <!--Scrollable content here--> 
     <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical">     
      <TextView 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:text="test text" 
        android:textSize="40dp"/> 
     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 
+0

कि अच्छा काम करता है दिखाने के लिए कृपया! धन्यवाद! – george

+0

मुझे एक ही समस्या थी। इस समाधान – zolio

+0

जब scrollview भरता है, यह बटन पर नहीं लिखेगा साथ अच्छी तरह से काम? – FractalBob

2

scrollview स्क्रीन फिट नहीं कर सकते,

सिर्फ XML लेआउट पर रूट elemen के रूप में scrollview बनाने की कोशिश

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
     <!-- Here you can put some XML stuff and BOOM! your screen fit to scrollview --> 

    </LinearLayout> 
</ScrollView> 
3

यह मेरे लिए काम करता है। स्क्रॉल व्यू 1 का वजन दें। लेआउट में स्क्रॉल व्यू के बाद सभी अन्य विजेट्स रखें। स्क्रॉल व्यू बाकी को अवरुद्ध करने के लिए पर्याप्त नहीं होगा।

Widgets in scroll view and rest at bottom

9
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
      <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Hello World" 
      /> 
      <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Hallo Welt" 
      />  
     </LinearLayout> 
    </ScrollView> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0"> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Go next page" 
      android:layout_alignParentRight="true" /> 
    </RelativeLayout> 

</LinearLayout> 
+0

हाय में इनपुट फ़ील्ड और पाद लेख के हेडर और स्क्रोलव्यू के साथ लेआउट है जिसमें कीबोर्ड आ रहा है कि पाद लेख भी नीचे स्क्रॉल करें। उस फूटर को नीचे ठीक करने के लिए। कृपया मुझे मदद करें – Harsha

+0

यह काम करता है कि मैं पिछले 3 घंटे के लिए समाधान खोजने के लिए संघर्ष कर रहा था। – chanakya

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