5

मैं एंड्रॉइड के लिए नया हूं, एक बहुत सादा सरल सवाल है, मैं टेक्स्ट व्यू में एक निचली पंक्ति कैसे जोड़ूं, ताकि यह 1DP के रूप में सेल के तल पर दिखाई देता है, यहाँ कोड अब तक बताया गया है: इस प्रकारमैं अपने टेक्स्टव्यू सेल के नीचे 1 डीपी लाइन कैसे जोड़ूं (तालिका लेआउट नहीं)

<?xml version="1.0" encoding="UTF-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="47.5dp" 
     android:layout_marginLeft="2dp" 
     android:layout_marginRight="2dp" 
     android:paddingTop="13dp" 
     android:background="@drawable/line_str" 
     android:paddingLeft="8dp" 
     android:text="@string/manage_categories" 
     android:singleLine="true" 
     android:textColor="@color/white" 
     android:fontFamily="Roboto-Regular" 
     android:layout_gravity="center" 
     android:textSize="16sp" 
     /> 

line_str.xml के रूप में:

<?xml version="1.0" encoding="utf-8"?> 


<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- This is the main color --> 
<item> 
    <shape> 
     <solid android:color="@color/black" /> 
    </shape> 
</item> 
<!-- This is the line --> 
<item android:bottom="1dp"> 
<shape> 
     <solid android:color="#252525" /> 
</shape> 
</item> 
</layer-list> 

सराहना की किसी भी मदद करते हैं। धन्यवाद!

उत्तर

6

मैं क्षैतिज रूप से विस्तारित 9 पैच छवि डालता हूं और इसे टेक्स्टव्यू की संभावित संपत्ति को जोड़ने के लिए जोड़ता हूं।

परत-सूची दृष्टिकोण का सवाल है इस प्रयास करें:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- This is the main color --> 
<item> 
    <shape> 
     <size android:height="@dimen/textViewHeight"/> 
     <solid android:color="@color/black" /> 
    </shape> 
</item> 
<!-- This is the line --> 
<item android:top="@dimen/textViewHeight"> 
<shape> 
     <size android:height="1dp"/> 
     <solid android:color="#252525" /> 
</shape> 
</item> 
</layer-list> 
+0

क्या है @ Dimen/textviewheight? –

+1

यह dimens.xml फ़ोल्डर में textView की ऊंचाई की आपकी घोषणा होगी। या आप यहां मूल्य को हार्डकोड कर सकते हैं। –

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