I will try to explain.
I have a ListView with its adapter which defines the method getView (as usual) for retrieving the appearance of the cells. The final appearance of the ListView is the one shown.
As you can see the first arrow is rotated of 180 degrees. It has been rotated with an animation once I clicked on it. If I'd click on it again it would be rotated to the original position again. The rotation of 180 degrees is maintained with the fillAfter parameter of the animation (then it is not fixed definitively once the animation completed).
The problem is the following: when list view is scrolled and the cell with the rotated arrow is brought out and in again the cell's view is loaded again. At this point I need to rotate the arrow again. I have two ways:
use arrow.setRotation(180f)
use the same animation used before with the duration set to 0
Both the ways have a problem:
The rotation is fixed, then when I call the method for rotating the arrow to its original position the arrow is ALREADY on its original position (because of setRotation)
The rotation is not immediate, then, when the cell is brought out and in again, for an instant it points right and after a moment left
How can I solve this problem?
I need to rotate the arrow before of bringing it in again but without fixing its state as rotated of 180 degrees.
I will suggest you if you have less posibilites of items to be placed in listview then use Dynamic Linearlayouts in ScrollView instead of ListView. As ListView generates many complexities in its own layout In making custom adapter like putting edittext in listview and do some action like delete/animation on UI component of yout listItem.
Related
How can i scale the last and first listview item (depend of finger position)?
For example, ListView, contains 10 elements. Visible only 5. We start scrolling, new element from bottom started scaling from minimal scale, old first visible element started scale down. If we stopped scroll (but not touch up) scale saved.
This is not animation in the usual sense. How can i to make it?
I am implementing a animated book in Android and the animations are defined by an XML (not an Android XML). The images are positioned in fixed positions and when user touches in a element on the screen, the app plays a sound and animate the imagebutton, changing the image src and positions (X and Y).
I want to know how can I do that. As images dot not have the same size, I think the sprites solution is not a good way to solve it.
Its like the image 2:
Thank you
There are two types of animations:
View Animation and Proprety Animation.
The view animation can only animate View objects. It also lack a variety of animations, since it can do only stuff as scale, rotate, move... It cannot change background color, for example. Also, the dissadvantage of the View Animation is that it only change the position of where the View object is DRAWN. Phisically, it still stays in the same position. That's why the button is unclickable, after the View Animation is finished upon it.
Property Animation, in the other hand, can animate both View and non-View objects and it doesn't have constraints as the View Animation. When objects are moved, for example, with the property animation, they are not just drawn on some other position on the screen, but they are actually MOVED there.
Now, Property Animation is a lot more complex to write than the View Animation, so if you don't really need all the advantages of the Property Animation, it is suggested to use View Animation.
Source: Property vs ViewAnimation
Tutorial and SupportLybrary up to API 1: Nine Old Androids
I have a panoramic background as a sky that i want to move from left to right and then from right to left to simulate a moving clouds animation as a screen background .
This should repeat indefinitely and after goin to the right most then return back to the left most..
I have tried the following:
Animation left = AnimationUtils.loadAnimation(MainActivity.this, com.icare.kids.R.anim.view_transition_out_right);
left.setRepeatCount(Animation.INFINITE);
left.setRepeatMode(Animation.REVERSE);
left.setDuration(3000);
findViewById(id.cloud).startAnimation(left);
But this does not seem to work... any solution for that ?
I am currently setting the image to an ImageView as follows:
<ImageView
android:id="#+id/cloud"
android:layout_width="3000dip"
android:layout_height="wrap_content"
android:layout_below="#id/topbar"
android:scaleType="matrix"
android:src="#drawable/bgpan" />
how can i set the image to the screen to start from the left most like this below, so to help in the panoramic animation effect:
The best solution that is efficient and fast on all phone ranges was to actually only animate the clouds while keeping the background static.
you can also add some variable to the speed that would add some randomization to the speed of the clouds so you don't get a monotonic looping.
Implementation details and solution was taken from this answer
One thing you might be able to try is using a Viewpager object with fake drag, where you continually re-add the background to new views that get generated, while disabling user input.
This will give the illusion of what you are trying to do.
So lets say you have 4 views in your adapter, each view contains just one of the image assets that fills the whole screen, and Viewpager's fake drag pans from View A to View B, draws View C and draws View D, then it fake drags from View B to View C and draws View A again
I'm curious if that would work for you
I see on the Galaxy Tab Email app or in My Files app (run on galaxy tab). The user can touch on a vertical line and move, the listview size change following user touch moving.
Like this video :
Galaxy_tab_email_app
I see that when user touch on the edge of the listview. A Vertical line appear. Like this image :
My question are :
How can the app appear the line with special red part on the image?
How the app resize the listview?
As my guess. The "line view" catch touch action, and when user move his finger, the app resize the listview (or listview's parent layout) size. But I don't know whether we have another way ?
Thank you and sorry because my english is not really well.
A guess, because I don't know how this app does it:
a. Create a custom view class and have properties which describe x,y, width, height etc. and a property for the y position to draw the pointer ("special bit in red").
x,y, width, height just describe the position of the bar. The pointer position is controlled by the listview depending on which item you select. Override the onDraw() method of the view to draw the bar. It's not difficult to draw shapes like this on a canvas.
http://www.stanford.edu/class/cs193a/06/
b. Override the onTouch() method of the class and capture drag actions on the bar. Use an Interface to register callbacks to classes which want to know when the bar is dragged, e.g. the listview on the left and the layout on the right.
Study the custom checkbox example here:
http://iserveandroid.blogspot.co.uk/
I have an image I can drag on the screen thanks to an OnTouchListener.
While moving this image I draw a thin line that "binds" it to its original position.
Now when I release/drop the image, I have a TranslateAnimation which makes the image go back to its position or out of the screen, depending on the dropping area.
How could I redraw the line during the TranslateAnimation so that the image is still bound to its original position while moving?
In AnimationListener there's onAnimationStart, onAnimationRepeat and onAnimationStop, but I see no trace of a onAnimationProgress or so.
Is there a way to get the changing position of a view while animating? Other than an infinite loop on the view position and an if to check if its position changed...
I think you can achieve what you want by creating your own Interpolator for the animation and then whatever you want when getInterpolation() is called.