2009-12-17 12 views
13

के शीर्ष पर एक सीमा आकर्षित करने के लिए का पालन किया है: http://www.connorgarvey.com/blog/?p=34मैं ढाल विभाजक के लिए में उदाहरण कैसे रेखीय लेआउट

मैं अपने रैखिक लेआउट के तल पर एक क्षैतिज रेखा आकर्षित करने के लिए कोशिश की है।

यहाँ मेरी रेखीय लेआउट फ़ाइल है:

 <LinearLayout android:id="@+id/test" android:layout_width="fill_parent" 
      android:layout_height="wrap_content> 

<ImageView android:id="@+id/icon1" 
    android:layout_width="32dip" 
    android:layout_height="32dip" 
/> 

और मैं

<View 
android:background="@drawable/black_white_gradient" 
android:layout_width="fill_parent" 
android:layout_height="1dp" 
android:layout_above="@id/test" 
/> 

जोड़ने किया था लेकिन मैं LinearLayout के शीर्ष पर किसी भी लाइन नहीं दिख रहा। और जब मैं पदानुक्रम देखने के लिए जाता हूं और देखता हूं कि वह देखता है (हॉर्ट सेपरेटर के लिए), getWidth() 0 है, जबकि getHeight() 0 है।

क्या आप कृपया मुझे बता सकते हैं कि मुझे क्या याद आ रही है?

धन्यवाद।

+0

किसी को भी कोई विचार है? – n179911

उत्तर

2

मुझे लगता है कि पैरेंट लाइनरलेआउट दृश्य में अभिविन्यास गायब हो सकता है;

<LinearLayout android:orientation="vertical" 

या यदि आप LinearLayout के बजाय RelativeLayout उपयोग करते हैं, आप के layout_alignParentBottom सेट कर सकते हैं;

<View android:layout_alignParentBottom="true" 
4
कोड आप पोस्ट के साथ

, इसकी पूरी तरह से तथ्य यह है आकार है कि ठीक है.पर 1dp यह प्रदर्शित नहीं हो। आकार में वृद्धि या के रूप में आप चाहते हैं केवल एक लाइन एंड्रॉयड

android:background="@android:drawable/divider_horizontal_bright" 
// this for white background only 

से इस डिफ़ॉल्ट पंक्ति drawable का उपयोग मुझे आशा है कि इस मदद से आप आप क्या चाहते हैं

1

यह नहीं देखा जा सकेगा यदि ऊंचाई 1DP है मिलता है। 2dp बजाय का प्रयास करें:

<View android:background="@drawable/black_white_gradient" android:layout_width="fill_parent" android:layout_height="2dp" android:layout_above="@id/test" />

1

काली बॉर्डर केवल तभी आकार कम से कम 2dp है दिखाया गया है। काला करने के लिए सीमा निकालने का प्रयास करें, और सेट ठोस रंग:

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#000" /> 
</shape> 

से आप फिर से 1DP की ऊंचाई का उपयोग कर सकते हैं।

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