Skip to content Skip to sidebar Skip to footer

Background With Directional Arrow

I have a quick question on how to achieve a desired view of a background on a view. What I want is a directional arrow pointing in a direction as the overlay on a background of say

Solution 1:

Something like this attached file would help? Created in paint, used then draw9patch to draw the stretchebale lines.

You might have seen the docs for 9-patch.

Created with paint, edited in draw9patch - 2 mins

Solution 2:

Actually this can work in a layer list. just from the top of my head you could do soemthing like this:

<layer-listxmlns:android="http://schemas.android.com/apk/res/android" ><itemandroid:left="10dp"><!-- offset from the left --><bitmapandroid:src="@drawable/arrow_icon"/></item><itemandroid:top="5dp"><!-- replace with the hight of your arrow --><shape><solidandroid:src="#FFFFFF"/></shape></item></layer-list>

Save it in your res/drawable as with_arrow.xml and then you can use it like this:

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/with_arrow"android:paddingTop="5dp"/><!-- should be AT LEAST the height of your arrow, might want to increase it a bit though -->

If you set this as the background of your textview for instance it should stretch it with the content.

On another note you should really look into 9-patching. It's really not that complicated see here: http://developer.android.com/tools/help/draw9patch.html

Post a Comment for "Background With Directional Arrow"