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 d开发者_StackOverflowidn'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~~
精彩评论