0

Is it possible to make a divider drawable that consists of 3 images - 2 are ends of lines and the middle should stretch. So the idea is to make something like at any layout - to have ends with a fixed size - like wrap_content and the middle part is to be stretched.

Is it possible - to make it in xml drawable or programmatically?

Thx in advance

4
  • so you can use a 9patch Drawable Commented Mar 23, 2014 at 13:28
  • or you can use your custom Drawable and draw whatever you like Commented Mar 23, 2014 at 13:59
  • how's that possible? if I do it in xml-bitmap - it doesn't allow me to stretch something Commented Mar 23, 2014 at 14:12
  • or you can use your custom Drawable Commented Mar 23, 2014 at 14:20

1 Answer 1

1

Like pskink said, you can use an 9patch drawable as the divider. To convert your bitmap to a 9patch, use the draw9patch utility in the tools directory in your Android SDK. Drag your bitmap into the draw9patch app window, then draw a black line on top of the stretchable area (on the topmost pixel line). Once done, save the bitmap as 9 patch (e.g. your_divider.9.png) and use it normally as a drawable for your ListView:

<ListView android:divider="@drawable/your_divider" ... /> 

More info on 9-patches available here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.