Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top