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.

有帮助吗?

解决方案

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

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top