Android writing over image in button - android

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.

Related

detect which part of image is clicked

I want to make an app in which I ll show a human body. when we click on any body part the organ name should be displayed with a toast. How will I detect which body part is selected. According to me i ll make small images for every organ. and place those images behind the main image. Is it the right way? How will I draw organs(Bitmaps or png images?).
I think an easier way to do it is to draw shapes or even buttons over your image, and define them as transparent so you don't see them. Then, using onClickListener you can capture what button is clicked and do whatever you want.
Check this for an example

NinePatch images does not stretch

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.

set up different clickable part image android

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)

Overlapping Text on Button

I'd like to create a button for a calculator with normal and secondary text on it. The picture below outlines it pretty succinctly. My main concern is getting the secondary text to scale well on different devices. This makes me think that I want to use a secondary text view, or find some way to use HTML to render the button secondary text in the button.
The problem I'm running into is that I have no idea what the most scalable and robust way of doing this is.
Is it necessary to create a custom button? Or is there some way to get the button's setText() with HTML.fromHTML() to place the secondary text at the top left corner? So far adding more lines makes the button stretch, and adding specific padding for the button doesn't scale to other devices. I assume a background 9 patch image using the secondary text won't work either, as larger buttons won't scale the secondary text.
Anyone have any pointers? Thanks!

How to Disable Image like Iphone in ANDROID?

i want to disable view of image in my app.(like iphone). when my activity is launch i show one Image in Imageview then if i click on image i want to make it disable it. disable in the sense it will become more transparent.
Thanks....
onClicking the ImageView
myImageView.getDrawable().mutate().setAlpha(70);
myImageView.invalidate();
this will make the image somewhat transparent. Lesser the value in setAlpha(), the more transparent the image will become.

Categories

Resources