Draw order in Android RecyclerView - android

I have a RecyclerView where I have enabled dragging to swap item order, however there's an issue with the draw order, sometimes when I am dragging one of the rows it is drawn under the other rows, instead of above them (this seems to happen most often when dragging an item down the list).
Is there a way to make sure that the view that is being dragged is always rendered on top of the other views?

Related

Is there any way to redraw only one View?

I have GroupView which contains 4 ImageViews.
When I change params of one view(for example re scale image or rotate) this causes to redraw whole Layout.
I want to prevent redrawing whole layout and want to redraw only specific View.
Sure.
myView.invalidate()
See:
https://developer.android.com/reference/android/view/View.html#invalidate()
Drawing is handled by walking the tree and recording the drawing
commands of any View that needs to update. After this, the drawing
commands of the entire tree are issued to screen, clipped to the newly
damaged area.
The tree is largely recorded and drawn in order, with parents drawn
before (i.e., behind) their children, with siblings drawn in the order
they appear in the tree. If you set a background drawable for a View,
then the View will draw it before calling back to its onDraw() method.
The child drawing order can be overridden with custom child drawing
order in a ViewGroup, and with setZ(float) custom Z values} set on
Views.
To force a view to draw, call invalidate().

Android animate appearance listview item

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?

ViewPager for matrix data

I want to use a view flipper which works on a matrix and not a list which allowes me to either flip vertical or horizontal - but both at the same time. I know there are similar on lists working implementations like the DirectionalViewPager but they work on a list and the user has to configure if they want to flip horizontal or vertical exclusivly. I have a situation like in the image in mind:
The blue area is the current visible element. The grey boxes are the fragments the user can navigate to and from.

Rotation of a view in a ListView's cell

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.

How do I get a ListView to draw over its list items?

I have extended ListView such that I can have a fast scroller. In the onDraw method I draw a rectangle with lettering along the right edge of the list, and if you are actively sliding your finger up and down I render the current letter in the center of the view. The problem is the list items render on top. Not idea.
I am looking for the best way to render my background, then my list items, then my foreground.
Override dispatchDraw() instead of onDraw(), and draw your fast scroller after calling through to the super method.

Categories

Resources