I am trying to make a really easy xml layout and I can't seem to get it to look the way I want.
I attached a picture of what I want it to look like:
Basically, I have a static background image in my imagebutton at the top. Below that I have a picture the user snapped in the Photo Box. I assume I need an image view for that, but would it be possible for me to instead pass the pic to the background of an image button too so I can make the size easier to manage?
Based on what the user chooses in the options before this layout, an option photo is shown based on what they select. The photo would display to the right of the centered image, if that option is selected.
Below that would be a centered text view, with another separate one below that. Finally, I would have two buttons on top of each other at the very bottom.
Could someone show me a good way to get this layout and also tell me if it is possible to take a picture that is snapped and make it the background of an image button - or if that is a bad idea?
Thanks so much!
Seems like for the most part, you just want a simple LinearLayout. For the part with the photo, you could use an embedded LinearLayout or RelativeLayout.
As for the picture - you can easily set the background of any view or view group to any image (any view has an option to set the drawable for the background).
The only thing you should consider - for the purposes of making the UI more intuitive - is to slightly modify the image for the different states (focused, selected, etc), so that the user gets visual feedback when selecting the button via the trackpad, or when clicking on the button. A "drawable" has built-in support for multiple images for each state.
Related
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.
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.
I made an app in Android, in which I put twelve buttons. When you click on a button, it will show you an image on the button. It's like an image puzzle game, with two buttons containing one image.
If the images match, then the game continues, but if the images do not match, it will disappear.
The only thing that I don't understand is what code and logic I should use if the image does not match and it will disappear.
Please help, thanks.
If you want to make something disappear and take up no space, you can set its visibility to 8 (which is invisible). Here I'm making everything inside a layout invisible.
LinearLayout buttonbox = (LinearLayout) findViewById(R.id.storybox);
buttonbox.setVisibility(8);
You can change the visibility of any kind of view. Here's the documentation.
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.
I am developing an application in which each Activity has a View which shows a PNG Image, followed by a TextView, an EditText and other views... The Activity's Content View is inflated using an XML layout file.
Depending on which options the user chooses/how he interacts with the application, I want to dynamically draw onto the PNG Image.
Is this possible? If so, how? If not, how else could I go about it? Could you point me towards a tutorial on this sort of thing?
Many thanks
Darius