android ListView child animation - android

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

Related

Android: Detect if user touches a view inside parent view

I have 40 ImageViews inside a GridLayout, they have different colors and I want to know if user touched the desirable image or somewhere else(for example if user touched red image). How should I do that?
Set an OnClickListener for each view and store the views. In onClick you can check the view and know what ImageView was clicked. You could also think about changing the type to ImageButtons!
If you have further problems with your Grid not being able to be clicked, check this out: http://cyrilmottier.com/2011/11/23/listview-tips-tricks-4-add-several-clickable-areas/
TLDR: Disable focusing of the views in your layout.
If you manage your images in a collection maybe think about switching to gridview and implement an adapter with an itemClickListener. So depend on which item is clicked do you action.
How GridLayout items come from the Adapter(List/Image) in Android App

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.

Android: Add image on top of each item in a listview

Does anyone know if it is possible to layer an image over the top of each item in a listview? To indicate that each list item is clickable, I'd like to add a small right-pointing arrow on the extreme right side of every item in the list. I'd like this image to scroll with the list.
I know that I can just create a horizontal linearlayout and put the image there, but this takes up some of the screen. I'd rather have it "floating" over the top of each item. Hopefully I'm making myself clear.
Thanks!
Short answer: don't do this, it directly contradicts Android UX guidelines, http://developer.android.com/design/patterns/pure-android.html
Long answer: post your xml/code for building the cell. It's probably enough to use a RelativeLayout and align an ImageView to its right side.
Again, this is completely unnecessary and an anti-pattern on Android. Don't do it.

How to slide views in Android

I have two image views in a table layout (two cells). Only one of the image views has an image displayed (the other is blank).
When a user taps on the view with the image, I would like the image to transition into the empty view.
Does anyone know how I can achieve this?
You could do it with a TranslateAnimation. If I were doing it, I would set the first one(which starts with the pic in it) to View.GONE, set the other to VISIBLE, then apply a translate animation to the second one that will slide it from the position of the first to where it is supposed to be.
This page has a nice tutorial on how to use various types of animations.

Drag ImageView in a Grid Puzzle to swap with another ImageView in the same GridView

I am trying to develop a puzzle that lets you drag the puzzle part to another part in the puzzle. This drag event shall swap the 2 parts (Images in my case).
I made the first part of the puzzle by making a GridView that contains the puzzle parts as ImageViews and a blank position. So, clicking on an image checks if it is neighboring the blank position. If it is neighboring, they swap. Otherwise, nothing happens because this part can not move.
Can anyone suggest how can I change "clicking" the image to "moving" the image to do the swap operation?
I put together a drag-and-drop grid view that you can get here:
https://github.com/thquinn/DraggableGridView
You'll have to change the animateGap(...) and reorderChildren() methods to get your intended behavior, but it should suit your needs.
you can use the onclicklistener to get the clicked image.
To 'move' the image try using addviewat() and removeview() functions on gridview to remove
and add the views.

Categories

Resources