2013-05-25 7 views
9

मैं LinearLayout ऊंचाई आधा fill_parent xml में कैसे कर सकता हूं?ऊंचाई आधा fill_parent xml

<LinearLayout android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:weightSum="1"> 
     <ImageView android:layout_height="fill_parent" 
       android:layout_width="0dp" 
       android:layout_weight="0.5"/> 
</LinearLayout> 

मुझे ऊंचाई के साथ कुछ ऐसा करना है।

+0

fill_parent के बजाय डीपी में आवश्यक मान निर्दिष्ट करें। 100 डीपी या जो भी आप चाहते हैं की तरह। – Raghunandan

+0

आप चाहते हैं कि आपकी रैखिक स्क्वायर हो? – Blackbelt

+0

मुझे सिर्फ 1 लाइनरलाइट के साथ आधा स्क्रीन चाहिए और – lexell

उत्तर

24

I just want have a half of screen with 1 linearLayout and half screen with other one

इस

<?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:weightSum="2" 
    android:orientation="vertical" > 

    <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="#192832"></LinearLayout> 

    <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="#193222"></LinearLayout> 


</LinearLayout> 

दो रेखीय लेआउट कब्जे स्क्रीन प्रत्येक के आधे की कोशिश करो।

+0

के साथ आधा स्क्रीन यह तार्किक है, धन्यवाद – lexell

+0

आप निश्चित ऊंचाई –

+2

के लिए layout_height = "0dp" का भी उपयोग कर सकते हैं ध्यान दें कि 'fill_parent' को हटा दिया गया है। एपीआई 8 या उच्चतर के लिए 'match_parent' का उपयोग करें। ([डॉक्स] (http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html)) – Keith

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