Android floating view through actions

Demand

I have an application with 2 actions, for example A and B , with navigations such as A->Band B->A(when pressed again). My requirement

  • I want the view / layout displayed on the screen, regardless of whether the activity is currently visible. I inflate this kind of start (onCreate of activity A) application, it remains static on the screen during the transition from A-> B and when B. is on the screen.
  • Thus, naturally, this view should be inflated only once (when the application starts, onCreate of A).

What i learned

I did a few searches, and from what I could find, there are two ways to reuse the layout in android

  • using <include>

    It just looks like a tool for writing xml code for commonly used user interface elements. It is pumped up every time it is used in the parent layout.

  • using ViewStub

    I did some research on using ViewStub, as well as a way to reuse a code segment in many layouts. It also needs to be inflated every time we use it in the layout, except that it only inflates when we make them visible at run time.

Another hint of my requirement

For people familiar with iPhone development, you can add a view UIWindowthat stays there, regardless of which is currently active UIViewController. I want the exact behavior in my application.

My initial setup

Android 2.1 . , Fragment API 11 (android 3.0) . Android, Fragment . . , - , .

30 , , . , .

+5
1

1: FrameLayout

, FrameLayout. FrameLayout . , .

http://developer.android.com/reference/android/widget/FrameLayout.html

, , "":

http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html

2:

. Fragments:

" , . , , , , ., ( ), , , . ​​ , , - - . ( ), "".

+2

All Articles