creating custom shape / drawable - 6 sided button - android

Is it possible to create a completely custom shape in xml? I'm trying to create a button which looks like this: http://s11.postimg.org/e4izrlgrj/image.png (a mockup i did in photoshop)
I need to be able to create the outline shape and the small blue tab top right.
I have tried with some xml but getting nowhere close. I'm aware you can do something with Path class but never used it, is this the only option?
Thanks

I don't know about a completely custom shape but have you tryed using font icons?
Take a look at this: http://css-tricks.com/svg-sprites-use-better-icon-fonts/

Related

Android custom rectangle

In my app i need to create cardview with curved top and bottom lines, like this:
I tried to search answer on stackoverflow and google but i haven't found anything. Also i tried to make it via xml, but i couldn't.
Can anyone help me with this? I can't use it like image background because i need to change background color when i click on card and i have a lot of such card in my recyclerview and a lot of different colors for every card.
Thx.
You need to use a custom shape a la this as the background of the view. edit see this post

How does Android do its spinner style with the triangle icon in the corner?

I've spent way too much time researching this, but I'm wondering if anyone can provide any insight to how Android does its spinner styling with the triangle dropdown indicator?
The reason I want to know is that I am using a custom textview as spinner item, and once I use that I lose the triangle. In addition, I want to make the triangle white.
I've seen previous answers with modifying the theme but I don't want all spinners to change so I don't want to modify the entire theme. I want to learn how Android does the triangle so I can recreate it. I tried using a list-layout drawable with a triangle shape but I'm wondering if there is a better way?
You can set drawbleEnd
android:drawableEnd="#drawable/imgresource"
create an image of how you want as your spinners background with whatever type or triangle and whichever color your want and then set that image as the background of your textview like this
android:background="#drawable/myBackground"
It a simple Nine Patch Drawable.
You can create a NinePatch graphic, set a black dot on the top and left to expand the top and left edges. With a triangle in the bottom right.

design a custom view like a tool tip

Does any one have any idea of creating a custom component like the below image instead of using the image itself.
I know how to create a rectangle (a rounded one using the xml and not in java) which was discussed in the link here but i am not able to work with something like the pointer part.
does anyone have an idea to do this i would be happy if i am suggested.
Create a class that extends PopupWindow and set the background through code so that you can replace its color.
Here is a easy sample PopupWindow: http://www.ceveni.com/2009/09/popup-window-in-android-sample-program.html
See this post to know how to change/replace colors in a drawable: How to change colors of a Drawable in Android?
The adjust() method from that post is enough for you.
Create a new PopupWindow, load the bg drawable, change its color and set the new drawable to the popupWindow.
You can make use of customized popup window. I never tried it before but you can give a try If you succeed please share it here....

Custom Button (Solid Left Arrow) in android using shape drawable in android

I want make a custom button in android left solid arrow (only arrow shape not its background).
How can I create this arrow button using shape drawable XML in android.
I know how to create rectangle button but not arrow.
Anybody who knows it please tell me how to do.
Sorry I can't post code, only show you where to go.
But the ultimate answer is to use a pathshape button. Then it handles everything for you.
Create the paths by following the information at http://developer.android.com/reference/android/graphics/Path.html
You can learn more about shapes at http://developer.android.com/reference/android/graphics/drawable/shapes/Shape.html
Finally you can learn about tying them together at http://developer.android.com/reference/android/graphics/drawable/shapes/PathShape.html
That way you can do it even in XML. And there's a variety of arc path methods. Check it out!

custom Button android like media player button

HI,
I'm trying to achieve a custom buttons . I'm wondering how I can achieve this with Android.
The result should look similar like this,
how I can make special shapes adjacent the problem it is because the image of each button must always be rectangle.
Thanks.
You can create custom backgrounds (shapes, colors, etc..) using xml drawables.
You should check out the documentation and the samples, like this one:

Categories

Resources