I am trying to create a drawable such as this in Android:
I don't think a nine patch will work because there is nowhere that can safety scale vertically. So next I tried a shape drawable but it does not support triangles.
I want to render this image on the fly so there are no artifacts. Also I want to be able to use it in a selector, so I need to be able to represent this image in xml. Maybe I need to extend some class to manually make the shape. If so how do I embed a tag in the xml to tell it where to render? Does anyone know where to start with this or have an example of something similar?
I have read the first 10 pages of hits on stack overflow and google and am not getting anywhere. Thanks very much for any help.
I think a 9-patch would work. For the vertical stretching on the left boundary, fill in the line from top to bottom.
Related
There is the concept of rounded corners for views and drawables in Android, however, am working on an interface for a kids robot, and someone asked for curly borders - sort of like wavy (sine wave kind of thing). Now, how the heck can one achieve such a thing in either XML or Java - especially, without resorting to use of image overlays or backgrounds?
rounded corners aren't in fact rounded Views, its just a bit of transparency in corners. you can create some custom drawables/Bitmaps and set for your Views (as a background or use ImageView) or you can use custom programmatic drawing like HERE
Have tried to use images of that form and use them as background in a transparent container?
I am having trying to accomplish this kind of a design. It needs to stretch to accomodate difference screens but rather then stretching it should repeat the pattern, I think the picture is pretty self-explanatory. 9patch only wont cut it as it only stretches.
Thanks for your time
The simplest method to do what you want would be to use a shape drawable with the stroke element set on it to obtain that dash pattern.
You may be able to also do it with a layer-list drawable.
Hello fellow Android designers,
I am struggling right now to create xml tooltip that would look like the one on this picture:
Unfortunately it seems like a hell of a work. Till now I was only able to create a simple rounded rectangle like that:
Is it actually possible to create such a shape I have presented on the first photo using xml styling or should I try to create it programatically (which will probably take huge amount of time and creating border would be really hard)? Or maybe the simplest solution is the best and I should use partially transparent png image with the shape of my choosing?
Any advice would be much appreciated.
You can draw it using stretchable 9-patch drawable.
You can specify there which parts are fixed (the little knob on the left and corners) and which are stretchable (all other parts)
iam stuck with the creation of a nine patch for a progressbar background.
It has a repeating pattern like a ruler-scala and that given me headache.
here is a image of what i want(at the bottom) and what i have (top).
can someone give me a hint how to acomplish my goal?
edit: or is it generelly possible to do this with a 9patch?
my other attempt was to make a with android:tileMode="repeat" but there i get problems with the height of my image (repeating in the second line), i need something like repeat-x.
Thanks in advance
edit2: ok i managed to do my repeating 9patch by stretching the whole repeating pattern, but its not ideal :(
You seem to be overestimating the power of 9-patches. The most you could do is have a ruler image with expanding space between the ticks. You can't, however, make a 9-patch that automatically tiles parts of your image.
On the other hand, if you create a BitmapDrawable programatically, you can set the tile mode separately for the X and Y axes.
I used to do this in my webview project using border image which provides both options (repeat, stretch, fill).
As webview has kind of it's own problems in android (mostly fixed element) I decided to be more android for the next project and I found out that it's not possible to have the repeated border using 9Patch. It's so awkward as it's needy but not implemented.
In a word android development area makes me crazy, one option here one option there is a usual thing here.
I'm using a layer-drawable and inside it I have one BitmapDrawable that repeats only horizontally. But I need to add borders for this drawable.
But I didn't find any solution for this!
I tried to create a ShapeDrawable and set my BitmapDrawable as background of my ShapeDrawable, but it's not possible.
I tried to find a method that add borders for my ShapeDrawable, but I didn't find it.
I also added 2 other images, that would be the box_top_left and box_top_right.
With this idea, I only need now to make it appear in this order:
box_top_left, box_repeat, box_top_right.
But i'm also having trouble to do this!
I've found a several ways to change a drawable's padding in my xml but not during the execution. I can't just set it on my xml because I don't know the total width.
And I didn't find any way to make my drawable the exactly width of my image.
Can somebody help me, plz?
I'll post some images to help you to understand what I want to do.
The first image is how it should be:
Inside my Dialog, at the top, above the text "Acesso ao sistema" I have my image that sould repeat.
I used a layer-drawable for my Dialog's background with a item that is the shape for my dialog and another item that should have my BitmapDrawable repeating only horizontally.
This second image is only missing to add my box_top_left and box_top_right.
This third image is what happens when I don't use borders:
And the last image is third image expanded for you to see the problem:
Thanks for your attention.
I think using a nine-patch for this will make your life a lot easier.
I think you can try Layer List, and define two items. One item is a shape which you can add stroke to be the border, and the other one is a bitmap which you can set tileMode to be "repeat" to repeat.
I used this method to implement my task. And I ran into one problem which already was fixed.The bug is that the repeat area seems have some lines between images.This may be caused by the shape having default black background. So I set the shape item's color to transparent.
Hope this will work for ya~~