android adding onclick events to parts of an image? - android

My layout file currently displays an image, but I would like clicking certain parts of the image to call different things, such as changing the content view/switching activities. Is there a way to make an onClickListener for certain parts of the screen?

Try creating an image map or you can use this link

Related

android: I want a(n) (Image)Button with two images on it

I am designing a calculator in android, and for that I need buttons with two images on them, one image for the button main function and the other for the button second function. I cant collapse them into one image because those two functions of the button have to be separately replacable.
Currently I 'solved' this with coding a layer-list and using it as the android:src for an ImageButton, but this seems clumsy and has issues when resizing.
Is there a better solution?
I am trying to stick with xml, by the way
I found a workaround/a better ansatz. Instead of using ImageButton with two images, I am now using a custom font that contains vector images as characters, and write with the font into a normal Button.

Android: Clicking on an image to switch to another image

What's a good way, both layout- and codewise, to accomplish the following:
Display one or more clickable images on the screen.
By default, the images are default images (duh)
When clicking on them, they change to a specified image
When clicking again, the change back to the default image
I cannot set all the images in the xml layout file(s), since I must be able to programatically set and change the images when clicking, and keep a record of the images on display etc.
In case anyone wonders: Yes, this is supposed to be a simple "memory" game, where I show x images, and click on two of them to display them, and give a result if they're identical.
I would suggest you to use ImageSwitcher, as the view, and setOnClickListener on the ImageSwitcher, to apply image changes on click action.

Simple full screen image in Android

I want to make it such that when a person clicks an image, it opens up in full screen.
What is the most effective way to do this in Android?
The simplest way I can think of is creating an activity, with a layout with the ImageView filling the whole screen. But I think there's some way to directly open just the layout or the ImageView with an Intent?
The Best way to do this is..
When you click on image open a full screen Custom dialog with the image in it having attributes fill parent. You don't need to go in another activity your purpose will be solved in 1 activity itself thereby increasing performance and also lesser activities will be in stack.

views / activities in android

I want to implement a design as visible in the following picture:
In the main you can see the small views. When you click one it maximizes to full sceen.
How do I implement this in Android?
There are multitude of ways you can implement this.
one way is to have the 4 contents as imageButton and when you click on it , it open a new activity which shows the content in fullscreen.
or you can use a tableLayout instead of imageButton
You could do it with images on the main screen, within say a gallery or grid view, that when each is touched, opens a new activity based on the image touched.
Links are to google android developers pages, showing information on the available view types and how to open an activity.

android custom button

I need to create some custom buttons as shown in the image below
what is the best approach to follow?
thanks
Abdul Khaliq
That's a hard one. I made a lot of custom views, and the first thing I would thinking of is, made one Button with that above image, and handle onTouch by yourself so you can distinguish which area the user hit. There you can also change the state of the button, like changing the image to a bevel one e.g. when the left button is hit.
Can you imagine this ansatz?
You can place two transparent "invisible" buttons over the top of a background in a LinearView. Like two ImageButtons with a transparent png inside.
It is also possible to make this background animated when buttons are clicked using android animation class.

Categories

Resources