0

i have an issue here. I have an .xml file in the drawable which is the android:shape="line". below is the code:

<stroke android:width="2dp" android:color="#FF00FFFF" />
<size   android:height="1dp"/>

when this .xml is applied to my linear layout as background as in figure below:

enter image description here

the left side and the right side of the line is touch to the linear layout. but, if i increase the "android:width" to '11', the line thickness will increase, but the left and the right side of the line didn't touch anymore to the linear layout as in figure below:

enter image description here

I want the line touch the left and the right side of my linear layout even the stroke "android:width" is increase.

please help.

squall leonhart
  • 301
  • 1
  • 5
  • 16

2 Answers2

1

You can also try to use linear layouts' divider property.

<LinearLayout
    ...
    android:divider="@drawable/divider_vertical">
  <TextView />
  <TextView />
</LinearLayout>

File: drawable/divider_vertical.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <size android:height="1dp" />
    <solid android:color="#FF00FFFF" />
</shape>
S. Lange
  • 11
  • 2
0

I already solve my problem :). It is simply put padding but not in the shape element because if I put in the shape element, the padding doesn't work. We must put the padding outside the shape region, or in other word, put padding in item region. Means that, the root element is layer-list, since item element and shape element is in same .xml file:

<item android:left="-7px" android:right="-7px">
<shape  xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="line">
        <stroke android:width="11dp" android:color="#FF00FFFF" />
        <size   android:height="1dp"/>
        </shape>
</item>

squall leonhart
  • 301
  • 1
  • 5
  • 16