Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 a textview.

For example (Beautiful MS Paint skills)

enter image description here

I have already tried using a layer-list which isn't going to work in this case due to screen size changes or fluctuating content heights. Is there any other possible way to do this other than using a 9patch. I've been dreading to even research 9 patches due to my complete illiteracy when it comes to graphic design.

like image 624
Brosa Avatar asked Apr 27 '26 17:04

Brosa


2 Answers

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

like image 103
gunar Avatar answered Apr 30 '26 06:04

gunar


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

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

   <item android:left="10dp"> <!-- offset from the left -->
       <bitmap android:src="@drawable/arrow_icon"/>
   </item>

   <item android:top="5dp"> <!-- replace with the hight of your arrow -->
       <shape> <solid android:src="#FFFFFF"/> </shape>
   </item>

</layer-list>

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

<TextView
    android: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

like image 35
Nick Avatar answered Apr 30 '26 06:04

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!