2012-02-03 9 views
5

जैसा लगता है कि ग्रिडलाउट हमेशा अपने बच्चों को उनकी आवश्यकताओं के अनुरूप लेआउट पर धक्का देगा। उदाहरण के लिए निम्नलिखित घोषणा:ग्रिडलायआउट अपने बच्चों और ओवरफ्लो को धक्का देता है जब ऊंचाई के लिए fill_parent

<?xml version="1.0" encoding="utf-8"?> 
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:columnCount="3" 
    android:orientation="vertical" 
    android:rowCount="4" 
    android:useDefaultMargins="true" > 
... 
    <ImageView 
     android:id="@+id/main_image" 
     android:layout_column="1" 
     android:layout_columnSpan="2" 
     android:layout_row="3" 
     android:scaleType="fitStart" /> 
</GridLayout> 

GridLayout fill_parent वाणी और इस तरह के रूप में मैं यह नहीं अतिप्रवाह की उम्मीद करेंगे। ग्रिडलाउट को माता-पिता का आकार लेना चाहिए जो इस मामले में खिड़की (पूर्ण ऊंचाई) है। हालांकि पदानुक्रम दर्शक में ग्रिडलाउट को ऊर्ध्वाधर और क्षैतिज दोनों के लिए Wrap_content के रूप में सेट किया गया है।

जैसे छविव्यू (जो एक बड़ी छवि है) या कोई भी टेक्स्ट व्यू स्वयं को फिट करने के लिए धक्का दिया जाएगा और इस तरह के ओवरफ्लो कंटेनर के रूप में।

यह पदानुक्रम व्यूअर के भीतर देखा जा सकता है जहां कंटेनर ग्रिड दृश्य माता पिता फिट बैठता है: छवि दृश्य अतिप्रवाह

image view

प्रलेखन पढ़ना

container grid view

, मैं समझता हूँ गुरुत्वाकर्षण स्थापित करने की आवश्यकता है। जहां तक ​​मैं कोशिश कर सकता हूं, मैंने बिना किसी प्रभाव के सभी प्रकार के गुरुत्वाकर्षण विकल्पों और छवि स्केलिंग विकल्पों का उपयोग किया। useDefaultMargins="false" के साथ मार्जिन को हटाने से लेआउट ओवरफ़्लो बदल जाता है जो ग्रिडलेआउट की ओर इशारा करता है।

मेरा प्रश्न इस प्रकार है:

  • यह एक बग है या मैं GridLayout गलत तरीके से उपयोग कर रहा हूँ
  • मैं कैसे अपने कंटेनर फिट करने के लिए और शेष रिक्त स्थान
+0

इस http://developer.android.com/resources/tutorials/views/hello-gridview.html – NagarjunaReddy

+0

मैं इस एक ही मुद्दा है, जब तक कि मैं पहला तत्व एक स्पष्ट ऊंचाई देने के लिए, यह लेता है देखना पूरे माता-पिता और बाकी की सतह को धक्का देता है ... – sethro

उत्तर

0
को भरने के लिए GridLayout के बच्चों मजबूर कर सकते हैं

अन्य लेआउट में चाल पहला तत्व एक एंड्रॉइड देना है: layout_weight = "1.0" और अन्य तत्वों के लिए कुछ भी नहीं। यह क्यों काम करता है मुझे कोई जानकारी नहीं है, लेकिन यह करता है। यहां एक साधारण एक्सएमएल है जो एक छवि दृश्य, एक टेक्स्ट व्यू और एक बटन प्रदर्शित करता है। ImageView को दिए गए लेआउट_वेट पैरामीटर के बिना टेक्स्ट और बटन को स्थानांतरित कर दिया गया था।

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/white" 
    android:orientation="vertical" 
    android:keepScreenOn = "true" > 

    <ImageView 
     android:id="@+id/imageView_surprise" 
     android:layout_width="wrap_content" 
     android:layout_height="0dip" 
     android:scaleType="centerInside" 
     android:contentDescription="@string/accessibility_imageView_surprise" 
     android:layout_weight="1.0" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_gravity="bottom" > 

     <TextView 
      android:id="@+id/textView_message" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:textColor="@color/black" 
      android:textSize="24sp" 
      android:gravity="center_horizontal" /> 

     <Button 
      android:id="@+id/button_share" 
      style="@style/button_text" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 

</LinearLayout> 
संबंधित मुद्दे