View being shown as merged with View beneath - android

I have two Views that are positioned on top of each other. The first stays in position and is visible at all times. The second has its visibility toggled by the user and slides in (and out) (using an animation) from (and to) the right of the screen. The problem is that the two Views when showing together, get merged such that you can see bits of the first View beneath the second View. Is there a property I can set on the second View such that it covers the first View totally out of sight?

Have you considered using ViewSwitcher?http://developer.android.com/reference/android/widget/ViewSwitcher.html

Related

RecyclerView LayoutManager - force to keep a view even if not visible

I am animating views between two RecyclerView. The first one is something like a list of folders showing the first item as cover, clicking it opens a new view showing the folders content animating the cover to the first item. Clicking back animates all visible views back to the folder where they came from (the cover being the top most view). This looks great as long as the opened folder shows the first item. If I scroll down the first item will be offscreen and the back animation does not look that good anymore because the cover view is not animated (I'm only animating all visible views currently).
What I think would work is following: the LayoutManager could position the first item at a position shortly offscreen and keeps it as a special view in it's pool so that u always can access the first view and when I animate back to the folder view I can animate the cover in addition to all other currently visible items ( the cover will be animated from top of the screen).
This means I need following:
the LayoutManager must handle the first item as a special one that is not recycled (I may need it any time for the back animation)
the first item must always be layed out (either at the default position in the list, if it is visible or offscreen directly above the screen), again because I may need it at any time for the back animation
Can someone help me where to start here? I think this is possible with extending the LayoutManager but I don't know where to start...
Have you tried the following?
recView.getRecycledViewPool().setMaxRecycledViews(TYPE_XXXX, 0);

Listview with one sticky header for second row

My layout is a bit complex.
I have a SwipeRefreshLayout in which I host a ListView. Whenever the user drags the Listview's top, the SwipeRefreshLayout performs a refresh. I also listen for the last visible item of the ListView to load next page of records (Endless scroll)
In the list's adaptor I have 2 views that I am using. The first one will only be visible in first row, the other view will remain the same for all other rows.
What I want to achieve:
On top of the row with position = 1 I want to have a sticky header. This means that when I scroll Up, the header will scroll to the top of the screen and will remain in there.
This sticky header will only be at one row
if possible I'd like to use a simple implementation as my layouts and adapters are already complex enough.
Waiting for your suggestions.
I didnt quite get your question the first time, heres the answer attempt round 2.
In your layout add an empty viewgroup (whichever you prefer, though linearlayout seems to work just great), add a scrollListener to your listView and check the position of your sticky view. If its top anchor is below (meaning its visible in the listview) the top of the screen you set the viewgroup visibility to gone, if the top anchor is either touching the top of the screen or below it, you add that view or one just like it to the viewgroup and set its visibility to visible.
You can adjust the position 2 view visibility accordingly to allow for this change to appear seamless. Can help you a bit more once you have some code and are on your way with this change.

Android - How to bring to front a webview

I have two Webviews but at certain point i would like to bring the one on the back to front. I want both visible.
Is it possible to change the layout order?
There is no concept of Z-axis position in Android view stack so you can't bring views to front or send to back. You need to set the view's visibility flag to hide, visible or invisible (.setVisibility(GONE , VISIBLE, or INVISIBLE) respectively). If you want them both visible at times then you need to have at least the top view (the one added to the parent view last) be with transparent background so that if their Visibilities are set to VISIBLE then the behind view will show through the top view.
Kevin

Flicker issue when scrolling views

I'm trying to convert the RealViewSwitcher based on the work from Marc Reichelt into one that is backed up with a ListAdapter. A horisontally scrollable ViewGroup that contains multiple views, where one is visible at a time.
My current solution adds at the most 3 views to the ViewGroup at a time. One (in the middle) which is visible and two buffered views, one on each side. When a user scrolls, say to the right, the left-most View is removed and a new View is added to the right. In order for the ViewGroup to be scrollable both to the left and right I need to always focus on the View in the middle. So, when a View is being switched, I arrange the Views correctly and sets focus on the View in the middle. The issue with this approach is that it suffers with a flickering effect when the Views are arranged. Let me illustrate the issue with a picture I drew:
A, B and C are three different views in my ViewGroup (the ListAdapter backing up the ViewGroup contains of more elements though, but only three are loaded at a time). The larger rectangle represents where focus is at the moment. I scroll to the left and at (3) I snap to the destination which is the left-most View. Then I re-arrange the view. I.e. Add a new view X to the left and remove View C to the right, placing A in the middle. Finally I center on the View in the middle (A) which was the one I scrolled to from the beginning.
So, when I do the last re-arranging of Views and center on A in the middle, the content of the View which was previously in the middle (B in this case) flashes a few milliseconds causing a flicker effect which is uncalled-for. Any ideas of how I can go around that?
Problem solved. The issue seems to be related to changing the childs in a ViewGroup and then call the scrollTo method. If I instead use a Scroller to move to the right view/child, the flickering issue disappears.

Sliding in a layout for user input

I have a ListView and each item contains a TextView displaying a number. I'd like to give my users the ability to change this number while staying on the ListView (as opposed to drilling down into a detailed view by clicking on the list item).
What I'm looking to do is to slide in a layout from the bottom of the screen that covers about half of the screen. I'd like this layout to be OVER the Activity behind it (as opposed to being part of that Activity's layout and simply showing it). I'd also like it to be model (or seem modal). Meaning the Activity behind it can not be focused and manipulated. In this layout I will essentially create a calculator.
What I need help with right now is:
1) How to display a layout over the current Activity
2) How make the background (the Activity) modal
Could someone point me to some tutorials/resources and/or give me a few tips?
use an Animation. here is a small tutorial on them: http://developerlife.com/tutorials/?p=343
initially, the view you want to be modal must be placed where you want it to show up(and visibility set to gone).
use a translate animation to visually move the view from below the screen to halfway up the screen. once the animation starts, set visibility to visible
try disabling all views that the user should not be able to interact with after you have started the animation holding the calculator view

Categories

Resources