6

http://img683.imageshack.us/img683/645/weatherscreenmockupoutl.pngग्रिड व्यू या टेबललाउट?

मैं खुद से पूछ रहा हूं कि इस लेआउट को कोड करने का सबसे अच्छा तरीका क्या है। मूल रूप से मुझे सिर्फ यह जानने की जरूरत है कि बराबर चौड़ाई वाले सात कॉलम कैसे प्राप्त करें।

अग्रिम धन्यवाद!

+0

तालिका लेआउट से कार्य करेंगे .... –

उत्तर

4

यदि यह समान चौड़ाई है जो आप चाहते हैं, तो आप बराबर वजन के बच्चों के साथ रैखिक के लिए जा सकते हैं। निम्नलिखित एक्सएमएल देखें।

<LinearLayout 
    layout:orientation="horizontal" 
> 
    <LinearLayout 
     android:id = "@+id/firstcolumn" 
     android:layout_weight="1" 
     android:orientation="vertical" 
     android:layout_width="0dp" 
    > 
    // do the same for your rest of the six children 

</LinearLayout> 
3

TableLayout बेहतर लगता है, क्योंकि कॉलम की संख्या बदलेगी नहीं। GridView के साथ आपको एडाप्टर और सामान जोड़ना होगा।

2

आप TableRow साथ TableLayout का एक अच्छा संयोजन है, और जैसा कि आप बहुत आसानी से चाहते हैं, पंक्तियों और स्तंभों बना सकते हैं। (एक LinearLayout insidea डाल उदाहरण के लिए)

यह 4 बटन के साथ 2x2 ग्रिड के साथ एक उदाहरण है:

<TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <TableRow 
     android:id="@+id/tableRow3" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

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

     <Button 
      android:id="@+id/button2" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </TableRow> 

    <TableRow 
     android:id="@+id/tableRow4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

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

     <Button 
      android:id="@+id/button4" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </TableRow> 
</TableLayout> 
0

सबसे अच्छा एक gridview उपयोग करने के लिए है। इस तरह someothing का प्रयास करें:

<GridView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:numColumns="7" /> 
+0

स्पष्ट समाधान की तरह लगता है, लेकिन स्थिर सामग्री के लिए मैं अभी भी LinearLayout साथ जाना चाहते हैं। ग्रिड व्यू को पॉप्युलेट होने के लिए एडाप्टर की आवश्यकता होती है। – timoschloesser

0
/> 
<GridView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:columnWidth="90dp" 
android:numColumns="7" 
android:stretchMode="columnWidth" 
android:gravity="center" 
/> 

कोशिश इस ..

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