2013-04-24 5 views
7

में नीचे के दृश्य गायब हो जाता है मेरे पास एक संवाद है जिसमें एक ScrollView के अंदर एक सूची है (TextView एस LinearLayout के अंदर)। लेआउट इस प्रकार है:स्क्रॉलव्यू एक संवाद

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

    <ProgressBar 
     android:id="@+id/delete_progress" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:visibility="gone" /> 

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

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

    <View 
     android:id="@+id/horisontal_separator" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="@android:color/darker_gray" /> 

    <LinearLayout 
     android:id="@+id/button_container" 
     android:layout_width="match_parent" 
     android:layout_height="48dp" > 

     <Button 
      android:id="@+id/load_button" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="@string/button_load" 
      android:gravity="center" 
      android:layout_weight="1" /> 

     <View 
      android:layout_width="1dp" 
      android:layout_height="fill_parent" 
      android:background="@android:color/darker_gray" /> 

     <Button 
      android:id="@+id/delete_button" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="@string/button_delete" 
      android:gravity="center" 
      android:layout_weight="1" /> 
    </LinearLayout> 

</LinearLayout> 

यह केवल सूची पर कुछ वस्तुओं के साथ इस तरह दिखता है: A few items on the list

लेकिन जब एक से अधिक स्क्रीन पर फिट कर सकते हैं (और स्क्रॉल करने के लिए वास्तविक जरूरत नहीं है) , मेरे बटन स्क्रीन के नीचे धक्का मिलता है। नीचे तक स्क्रॉल करते हैं, यह इस तरह दिखता है: A lot of items on the list

मैं LinearLayout बटन युक्त पाद लेख के रूप में रहने के लिए, यह कहीं भी स्क्रॉल नहीं करना चाहिए और स्पष्ट रूप से गायब नहीं की जरूरत है। मैंने लेआउट ऊंचाई और वजन के साथ झुकाव करने की कोशिश की है, लेकिन इसका कोई फायदा नहीं हुआ है।

+0

क्या आपने ListView को निश्चित ऊंचाई पर सेट करने का प्रयास किया है उदाहरण के लिए 200 डीआईपी? – Demonick

+0

मेरे पास वास्तविक 'ListView' नहीं है, लेकिन 'LinearLayout' की ऊंचाई को बदलने से कोई फर्क नहीं पड़ता है। और यदि मैं 'स्क्रॉलव्यू' की ऊंचाई बदलता हूं, तो यह बटन को फिर से धक्का देता है। – j0ntech

उत्तर

19

मुझे लगता है कि आप स्पष्ट रूप से की तरह

<ScrollView 
    android:id="@+id/filename_scroll" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > ////say android:layout_height="50dp" 

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

ऐसा scrollview के layout_height उल्लेख करना चाहिए scrollview

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

यह पूरी तरह से ठीक काम कर रहा है। क्या आप कृपया बता सकते हैं कि यह क्यों और कैसे हो रहा है? –

+0

यह मेरे लिए भी काम करता है! यह क्यों काम करता है पर एक स्पष्टीकरण पसंद करेंगे। – Vinnie

0

में बदलने की कोशिश। और दूसरा विकल्प है, लेआउट_हेइट को स्पष्ट रूप से निर्दिष्ट करके तालिका लेआउट जैसे बाहरी घटक को प्रस्तुत करें और इसके रूप में अपना स्क्रॉलव्यू शामिल करें।

यह काम करता है कि आप प्रदर्शित करना चाहते कस्टम संवाद के लिए XML लेआउट नीचे

+0

मैं कुछ भी स्पष्ट रूप से निर्दिष्ट नहीं करना चाहता, क्योंकि सूची में वस्तुओं की संख्या के आधार पर आकार बदलना चाहिए। वैसे भी, उमेश के जवाब ने वही किया जो मुझे चाहिए था। – j0ntech

+0

यह मेरे लिए काम करता है। स्क्रॉलव्यू एक कंटेनर के रूप में काम करता है और मैं गतिशील सामग्री का उपयोग कर रहा हूं। 20nos से अधिक। वैसे भी, खुशी है कि आप इसे –

0

उपयोग आशा है,

<FrameLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ListView 
     android:id="@+id/gameList" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="30dip" /> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" > 

     <Button 
      android:id="@+id/load" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Load" /> 

     <Button 
      android:id="@+id/delete" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Delete" /> 
    </LinearLayout> 
</FrameLayout> 

और से इस तरह इसे कहते आपके कक्षा फ़ाइल,

>  Button getList = (Button) findViewById(R.id.getList); 
>  getList.setOnClickListener(new View.OnClickListener() { 
>  
>    @Override 
>  public void onClick(View v) { 
>  // TODO Auto-generated method stub 
>  final Dialog listDialog = new Dialog(MainActivity.this); 
>  listDialog.setTitle("Load a game"); 
>  listDialog.setContentView(R.layout.custom_dialog); 
>  
>  ListView gameList = (ListView) listDialog.findViewById(R.id.gameList); 
>  gameList.setAdapter(new ArrayAdapter<String>   (MainActivity.this,android.R.layout.simple_list_item_1,new String[] {"your array" })); 
>  
>  Button dismiss = (Button) listDialog.findViewById(R.id.load); 
>  dismiss.setOnClickListener(new View.OnClickListener() { 
>  
>   @Override 
>   public void onClick(View v) { 
>    // TODO Auto-generated method stub 
>    listDialog.dismiss(); 
>      } 
>   }); 
>  
>   listDialog.show(); 
>  
>   } }); 
+0

समझते हैं कि 'मार्जिनबॉटम' सामान बहुत चालाक है, लेकिन मुझे पहले ही जवाब मिल गया है। इसके अलावा, मेरे मूल लेआउट में 'ListView' भी नहीं था। क्या आपने सवाल भी पढ़ा था? – j0ntech

+0

हैलो जोनटेक, मैंने इसे पहले ही पढ़ा है और मैं आपको इसके लिए वैकल्पिक समाधान सुझाता हूं। और यह नमूना आपके उद्देश्य की सेवा करता है और यह नमूना चला रहा है। क्या आपने इसे देखा? –