Relative layout, overlay - android

I have RelativeLayout with a number ImageViews, which are added dynamically. Each view overlap 80% of previous view. I want to add onClick listener for views, but I have a problem:
OnClick event works like I've clicked on the last (top) view, even if I clicked on any other.

newly added view's are overlapping by a fixed proportion (80 % ) so you can relate cordinate of touched point and selected view easily . so instead of ClickListener on ImageView use a touchListener on RelativeLayout .
for more help share your code .

It could be possible that, although the image inside the ImageView is.. say 100x100px, that the ImageView itself is taking up the rest of the screen with the image resource centered.
Hard to say without code.

Related

Expand an image in gridview when clicked in Android

I am implementing a GridView which contains images.
I want to expand an image to occupy the whole row when it's clicked as shown in the images below.
I also want to show a button when the image is expanded so the user can take an action similar to how the ESPN app does that.
How can I achieve this?
---->
Surround your layout with a relative layout. Create a layout and a button inside it outside grid layout/inside relative layout. Set it's initial visibility to gone and match it's height, width to row you want it to encompass. Then in the onclick of the image set the layouts view to visible and it's button. Perhaps not perfect but it has the added benefit of allowing scrolling of your gridview while showing the big image you want.

Overlap Item Gridview Android

I'm implementing the UI like the picture below. I'm using gridview to this layout. When user tap the item in gird. It show a circle overlap to the other item. I don't how to do it. at first I define a layout with the circle is gone and add onclicklistener. If user tap on that, I visible the circle, but the size of gridview also extend. Can you help me provide solution?
You can add this views in gridview parent layout preferable relative layout. You must add them after your grid view initsialisaton is done and onitemclick listener on grid item to make them visible. Exactly the one you've tryed but not in grid view but in the activity rootlayour.

How Cover the whole screen by textview irrespective of other elements present in the XML file?

How can i cover the screen by TextView i written Below but it does not work
I want the Facebook buttons to show sometimes i dont want them to show i just want to show a
Thank You for your help
Either re-order your RelativeLayout to place the element you want on top at the bottom of the layout list, or use a FrameLayout. A FrameLayout will allow you to overlay elements.
See here:
Android overlay a view ontop of everything?
The problem here is very simple. You are adding your TextView first and then you are adding ImageView. Both these are set to match parents width and height but since you are adding ImageView later its z-index is greater than that of TextView.
To confirm these just remove the ImageView and then check.
Hope this helps :)

android ListView child animation

I build a Listview, each item of this Listview in a layout composed of a Gallery.
On click of an item of the Gallery, I want to translate it to the top of my screen.
Even with setZAdjustment(Animation.ZORDER_TOP); my gallery cell doesn't move outside the gallery.
I assume it's because it can't go outside it's parent view.
Is there a way to do this ?
Thanks
I assume it's because it can't go outside it's parent view.
you are right.
There is no way that you can move that exact view. What you can do is make yourself a new ImageView and add it to your top level layout right over the top of the selected cell. Set its image by calling .getDrawingCache() on the gallery cell. Then you can animate your new ImageView to where ever you want.
Depending on what you want to do with it once it has been moved this might work out for you. But fair warning it is a somewhat convoluted process to achieve the effect you're after

Add buttons on an imageView

I'm trying to display an imageView with some buttons on it.
My problem is that I don't find any way to add my buttons at a specifics x and y on the image, can you tell me a function to do that?
Thanks.
You could put the ImageView and a AbsoluteLayout inside a FrameLayout. Then add your buttons to the AbsoluteLayout.
An ImageView is not capable of having children objects within it. The ImageView and Buttons would have to be two child objects within a Layout. If you want the button to appear on top of the ImageView, place the code for the Button after the ImageView code in the layout.

Categories

Resources