If you take a look at this app (https://play.google.com/store/apps/details?id=fr.recettetek&hl=en_GB) you'll see it provides image views with a little trash can icon in the top corner which deletes the image. Also the image views have borders around them and show the images without changing their length to width ratio. How is it possible to provide these features or any other feature in image views? Generally how is it possible to customize image views and make them more practical?
ImageView by themselves are used only to display a particular image. To have a custom behaviour or UI, such as the delete icon, you need to make a custom view.
You can do so by extending one of the ViewGroup, such as a RelativeLayout, and make your view.
For details on custom views, please refer to: https://developer.android.com/training/custom-views/create-view
Related
I want to display image view like below where one image will be below other. I'm using Picasso to set image. But it is setting image in entire space whereas I want to set only on the top layer. How to achieve this.
Any help would be appreciated.
Use StackView.
https://developer.android.com/reference/android/widget/StackView.html
I've only used a widget application, but I probably think to be able to use it on other scene.
The task is to make chat dialog to be like this image how can i make the background of every item to match this design i'm thinking about using card view but how can i add the extra slice for every item please help.
Update:
Here's the image for anyone in need:
You need to provide special images with extension .9.png. It calls 9-Patch files.
Here is more info about them.
In short, you need to create a simple png file with message background and in border of image mark extensible parts of image by black lines. Thus you will have opportunity to resize your image, but don't affect to it corners, for example, or some parts, that you don't want to resize.
Hope this helps.
Here is image to show, what can be achieved:
I would like to make a simple Android game where a large background image is displayed and some other images are displayed in specific locations over it, where the other images may be clickable.
Here's a quick sample image of what I'm talking about:
The user should be able to tap the soccer player or the moose (ah, the classic "soccer player moose problem"!)
How should I render this screen (which layouts and views?) so the user can interact with it and it will scale properly on different devices?
I would use a RelativeLayout.
You can set the you background image to the layout (fill_parent for height and width).
You can then put your ImageViews, containing your moose and soccer player down on the layout relative to the top or sides of the sceen, or relative to each other (making sure to specify "dp" units for everything). Set the backgrounds of your ImageViews to be transparent, and there won't be a bounding box problem (and/or you can also set your ImageViews alignment to be relative to each other, ensuring they don't overlap).
I think this is the simplest way to do this - it is then super easy to attach onClickListener to your ImageViews in your Activity, and you are done.
This type of layout will work the same on all devices and screen sizes.
There are some small gotcha's with RelativeLayouts, but they are pretty simple once you get into them, and provide fast rendering (since the view hierarchy is usually shallow). Good Luck.
ImageView for the clickable elements seems like a fine choice to me. For the background I would just set your image as the background of the parent layout i.e. RelativeLayout
SurfaceView for the whole thing (with your field as a background) and regular *ImageView*s for added elements. You can easily recover the click coordinates from the SurfaceView and thus know what element has been touched.
SurfaceView might offer you additional possibilities anyway.
For most images, I'd use an ImageView for each one, like FoamyGuy said.
If they're close enough for overlapping bounding boxes to be an issue, you can still use an ImageView for each, but with a variation of this answer, testing alpha for each ImageView in range.
I would agree with both FoamyGuy and Booger that if your only goal is to place static images onto the screen that do something when you click them, RelativeLayout and ImageViews all the way.
But...
If you are looking to randomly spawn multiple images onto the screen in intervals and have them move around for the player to interact with while explosions are going off and maidens are being kidnapped, you should look into SurfaceView, Canvas, Drawable, TouchEvents, and FrameBuffers.
I am creating an app which is a guide. I have a photograph showing an example, but I need to know, how can I make certain parts of the images clickable, to go to another activity to show more details about that thing.
Or have an image (which will be clicked) on top of the base image?
Thanks
have an image (which will be clicked) on top of the base image?
1 -
Can set the Background of Linear layout and add imageView in center of parent.
or
2- Use relative layout with tow image Views
You can split your main image on rectangular parts, then put them as ImageViews using RelativeLayout or TableLayout (which ever fits best in your case) so their combinations looks like a single image.
On each ImageView you can set a click listener using View.setOnClickListener(View.OnClickListener l)
i am trying to create the following UI in android app
In the above image all the five are to be image buttons. How to design this UI as like in the screen shot please help me friends....
Inside LinearLayout take RelativeLayout and make it centrally aligned.Then
Take first image Near me and set it's property.
Now take the second image Explore and set it to right of first image.
Place third image My network and place it below first image.
Fourth image Live set this to right of third image and and below second image.
Now center aligned your center image.
You will need to create 5 images, each of which has transparent areas. This layout type lets you position elements relative to the layout group itself, as well as to items within the group.
I'm not very familiar with Android advanced layout design, but the common layout objects give an idea:
There is a SurfaceView which gives you the ability to manipulate z-coördinates. In the SurfaceView you can then place a Grid/Relative/TableLayout for the 4 buttons (which you pre-render as rectangular images with transparency) and a simple Layout which centers and only contains the middle button.
If you then set the Z value of the first layout to less than that of the second you will get the view you want.