I've created this nine patch image.
I've used it as button background. In the button I've also put a text "back", but here is the result.
How can I put a text to the right of the arrow and let the image stretches in order to fit it?
(Don't worry about it's pixelated)
First of all as I can see you are creating the image in the wrong way. You can use this tool link . It's very useful at first steps.
Second of all in my opinion just remove that arrow from the background image. Leave it only
the yellow color with the gradient and add thet arrow as
android:drawableLeft="#drawable/my_arrow"
as element to your button in xml. That's the best option which I can think of.
Related
I've been messing with android recently and i've gotten up to the point of changing the look of buttons. I've created an xml file in drawables for the state of the button and created an android:background="" line to refer to the xml. I've been searching for quite some time and it looks like no one else has asked the question.
This is what I get:
This is where the buttons are suppose to go:
How/Where would I set the size of the button image to match the actual button?
Also an additional sort of Off Topic question.
How do i make the image to only show the button and not the transparent parts of the image?
I think you can create 9-patch background image for your button.
Here is about 9-patch information: http://developer.android.com/tools/help/draw9patch.html
You can always use 9 patch images to make them stretch over the button. this link will help you create a 9 patch image
Im working with android about image and onclick listener. The purpose of my app is to monitor the area that user clicks on the screen. For example, I have a picture containing a rectangular and a circle. Assume that the color of the whole picture is brown(wood). So when I click on the rectangular, the color of rectangle will change to yellow. When I click on the one part of the picture, the color of that part will change its color, but other parts do not change. So, Im thinking about the solution for this app. Do I have to cut this picture separately and put them into the screen by using relative review? Or is there any other way to do this(Set up a coordination system)?
Yes you have to cut this picture separately and put them into the screen by using relative review. For example two ImageView with your backgound.
You can slse the image as recommeded by the other post, or overlay the image with a RelitiveLayout with specific sized buttons (background = #android/color/transparent)
I am trying to create a stretchable scroll handle for my app.
The first image is the scrollhandle.9.png that I include in my app's resources.
The second image shows what this 9patch image looks like when used in my app.
Any advice on how to accomplish a stretchable scroll handle?
Edit: With help from posters, I was able to get an image that works. I added it below to help those who may find this in the future.
The area covered by the top and the left black line(dots) will be used while scaling your image. This area will be highlighted to you when you click the "show patch" option. You can see how the image scales by using the "Patch scale" option given in the draw9patch tool.
The area covered by the right and bottom lines(dots) will hold the content for the background.
Eg: You can define boundaries for the text inside 9 patch image for editor background. For your case you don't need right and bottom lines.
So for your case place two dots at the top corner and two dots at the left corner. Make sure patches doesn't fall in the arrow image of the scroll(if they do fall your arrow image will also get stretched) . Try putting the dots only in the left and top lines till you get the desired preview with "Patch scale" option.
If you use only one dot (instead of four) at the top and bottom left, and one at image top center, it should stretch the way you want it to.
If I have a custom image can I write over it, will it always write to the center of the button image? Ie will setText on image always right to center of the image provided or do I need to do something to have this effect? Thanks Also is it better to use ImageButton or set Image as background of Button? and write over it that way. I want to use 3d images and write on top of them in black text.
I don't know if there is a preformance difference for using image button of a normal button, but I'd imagine that and image button will work better. Albiet I always just use a normal button and setBackground(...). Also if you want to set the text to always be in the middle, use android:gravity="center" in the layout file.
i want to make a breadcrumb for my android app.
In breadcrumb on the left there is an imagebutton with arrow border. On the right there is a text title. When user tap on imagebutton, application performs specific task.
So, can you help me to create imagebutton with arrow border like in attach image?
Thank you.
I'm not 100% sure what you mean by an Arrow Border, but you cannot (as far as I know) set borders to any views in Android.
There are two options you could go for:
Make an outer View to surround the View you want a border on. Then set the background of the outer border to an arrow background.
Use a Nine Patch.
I would recommend a nine patch for this personally.
Edit: I noticed you wanted a border on an image. That could be an issue with nine patch unless you integrate the border into the image, which defeats the purpose.