Fernando Tan
Fernando Tan

Reputation: 644

Create shorter border than its view by using android drawable layer ist

I have been searching on how to draw a border line that has shorter length that it container for few days. Basically I want to achieve below results i.e borders that do not have reach its edge. enter image description here

So far this is what I have achieved: enter image description here

I was thinking it is impossible and not supported by android drawable, until I found this post Howto draw a half border in xml android . It illustrates how to draw a C shape border by using android drawable layer list. I tried to modify and fit into my purpose, but I cannot achieve the expected result

I am not good in android drawable and please let me know if you have any idea.

Upvotes: 1

Views: 114

Answers (2)

shaik subhani
shaik subhani

Reputation: 169

First you take outer rectangle box and align to a layout, and then take inner lines separately and add them using inner layouts.

Inner layout align:

<View
  android:layout_margin="5dp"
  android:background="#9c9c9c"
  android:layout_width="2dp"
  android:layout_height="desired"/>

Upvotes: 1

Mohit Kacha
Mohit Kacha

Reputation: 504

<View
  android:layout_margin="5dp"
  android:background="#9c9c9c"
  android:layout_width="2dp"
  android:layout_height="@dimen/view_sise"/> 

enter image description here

It will look like this.

Upvotes: 1

Related Questions