Android Ghost Layout on Activity Transition - android

I noticed something strange today and i'm not sure the best way to describe it.
I have two activities (A and B). I'm on A and start a new intent for B. I override the pending transition to be a slow slide up. This part is fine.
When B is sliding up I noticed that I can still tap on the screen where B's buttons would be and use their actions. (example, there is a close button to close B. When I tap on it's destination area it will close B even though it hasn't completely gone up).
My current solution is to disable all of the buttons until the animation is done. This is working fine, however I'd be interested to know if there is a better (more standard) solution. If anyone can explain (and confirm my suspicions) then that'd be a nice plus!

This is the expected behavior. Android is simply animating a transition and not actually moving the views from one physical location to another.

Related

Delay (or not at all) Display of Snackbar

A very odd issue that I'm not able to diagnose or figure out, so I'm hoping that someone else has seen this and might have a clue as to what's going on.
All Activities inherit from AppCompatActivity.
The scenario is as this:
Activity 1 (extends AppCompatActivity) starts Activity 2
Activity 2 performs some action after user input and then exits via onBackPressed
Activity 1 displays a Snackbar based on the action performed with Activity 2 as a means of confirmation
The problem is that the Snackbar doesn't show at all or is delayed and flickers on as it is dismissing. If I touch the screen and interact with Activity 1, the Snackbar becomes immediately visible.
I also turned on "Show layout boundaries" via the Developer Options and I can see that the Snackbar isn't actually being displayed (invisible) until I touch the screen (or until it starts to animate out).
I created a sample application and it seems to be working fine there, but no such luck in our production application. Activity 1 itself is displaying a lot of information and content in a ScrollView, but I wouldn't think that this would cause an issue, unless there are rendering passes that are happening that I can't tell and that is causing the delay in display.
I've created a project that you can use to demonstrate this problem. I believe that this is a bug, and you can work around it by not using your own transitions. Though I also believe that not all transition animations will cause the issue. I think the hold animation in this case is the culprit.
Here is a brief outline of the issue:
Activity 1 and 2 both have Scroll Views with a bunch of content.
Activity 2 opens Activity 2 using overridePendingTransition( slide_up, slide_down), though this isn't necessary for this example.
Activity 3 displays content and then is closed:
a) using overridePendingTransition( hold, slide_down ). In order to see the Snackbar in this scenario, you will need to touch the screen and interact with Activity 1.
b) using no Transition. The Snackbar should be visible.
My solution to this issue was to remove overridePendingTransition. Please comment if you have additional ideas about this.

Android activity switch animation background

What I want to achieve is a flip animation when going from activity to activity.
I've seen a recommendation somewhere on SO, that I should use appropriate layout animation in one activity, switch to next one without any animation whatsoever and then execute the second half of the animation in the second activity.
I guess it could work, not tried it yet. But what bothers me is more general aspect - I believe it should be possible to achieve the same effect with activity transition animation, but...
Somewhere (I guess it was SO, but I can't find it now) I've read that during the activity transition animation the background should always be fully covered by the animated activities. I'm not sure why - I can see the background is always black on all my devices, and making it visible during the animation appears to be harmless.
But perhaps it is not guaranteed? Can someone confirm that requirement? Is it officially stated anywhere?

Android onTouchEvent focus the whole activity

I'm working on a viewFlipper that switch between listviews, and so far, so good. I launch animations on a onTouchEvent. My problem is that to go in the onTouchEvent, I have to tap on a area empty of component, like if my activity is the last component to ask for the focus.
I want the exact other way around. I want that wherever I tap on the screen, despite of the others components, it launches the onTouchEvent. Must be simple but so far I did worthless research.
Thanks.

Animation in Android

I want to override the default animations (actually transitions) in Android, when an Activity comes on screen or goes off as the user presses the Home or Back button. I've tried the ViewFlipper, but that works only on single Activity with multiple views. I'm developing for Android 1.6. Any hint, how to do this?
So perhaps you should take a look at: Android transitions Slide in and Slide Out
It sounds very much like what you want.

Android Activities vs Views

Sorry, I know that this topic has been covered a bit. I've read the related posts and am still a bit confused. I am working on an app that while the prototype will have 3 main screens, it will eventually have dozens. Each screen will present either dynmically changing status or take user input. To visualize, it is required to be laid out similar to how MS Word or a typical PC is. It has a status bar at the top and a navigation bar at the bottom that is common to all screens (slight tweaks for some screens, like different icons) in the middle is what I would call a view pane that needs to be updated with a applicable layout.
The status, nav bar, and each screen are defined in their own layout xml file. For my first swag at it I just used a ViewFlipper and loaded the 3 screen layouts into it. However that means that currently I have one main Activity which will not be maintainable as I continue to add screens.
It feels right to me that each screen layout should have an associated Activity class that understands how to control that screen. I need to figure out how to load that into the center pane dynamically. However I thought I read in another post that using multiple Activities can be a CPU and RAM drain.
Currently I tried making one of the screens it's own Activity and kick that off from the main Activity by creating an Intent and than calling startActivity. However that causes the new screen Activity to reside on top of the main Activity. The interesting thing is that then pressing the back button dismissed that activity and returns me to the main.
So far I haven't figured out how to setup having a different Activity control what happens in the center pane.
If I continue down the multiple Activity path, should my main Activity be inheriting from ActivityGroup?
Are using View classes more applicable in this case?
I know this has been a long post. I'd appreciate any advice.
Thanks!
CB
As you noticed, Android will implicitly track a stack of started activities in a task, and the 'back' button ends the top one, reactivating the next one down. I would advise you to think about which kinds of things the user might expect the back button to do, and make it so that activities are separated along those lines.
I haven't played with ActivityGroup so I can't advise you there. If you go with completely separate activities, you can have them all use the same "shell" content view with the common nav/status bar. Have a superclass or utility class handle populating and managing that from there. Then use a a LayoutInflater (you can call getLayoutInflater()) to fill in the middle with your Activity-specific view.
If you want one of the activities to have multiple screens, you might still end up with a ViewFlipper in the center slot. Again, you want to have an Activity transition wherever you want the user to be able to go "back"; that also means you may NOT want to have a change of activities in cases where screens are closely related or part of the same logical thing-being-done. (You can override the back button's behavior, but unless you have a good reason to, it's best to just arrange the app so that Android's basic setup helps your app's UI rather than working at cross purposes.)
If you want to use activities in the fashion you talked about, you might look into using a tab activity. It actually works in the way you want, you just need to hide the tab widget and put your navigation bar there instead. Or, you could go a little deeper and make you own similar tab-like ActivityGroup like Walter mentioned if you have more time.
You could use a view pager with fragments to accomplish the flip between the different views but still allow your activity to have full control over it. The activity can control the menus while the fragment controls your viewing area. This way your back button will properly dismiss the activity containing all pages related to the activity instead of walking down the stack.

Categories

Resources