Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:39:57+00:00 2026-06-05T23:39:57+00:00

Requirement I have an application with 2 activities, say A and B , with

  • 0

Requirement

I have an application with 2 activities, say A and B, with navigations like A->B and B->A (on back press). My requirement is

  • I want a view/layout floating on screen, irrespective of which
    activity is currently visible. I inflate this view on app
    start(onCreate of activity A), it remains static on screen during the
    transition from A->B and when B is onscreen.
  • So naturally this view should be inflated only once (when app starts,
    onCreate of A).

What I found out

I did some searching, and from what I could find, there are 2 methods to reuse layout in android

  • using <include>

    It just seems like a tool to write xml code of commonly used UI elements. It gets inflated every time it is used in a parent layout.

  • using ViewStub

    I did some research on using ViewStub and It also seems a way to reuse code segment in many layouts. It also need to be inflated every time we use it in a layout except it gets inflated only when we make them visible at run time.

Another hint of my requirement

For people familiar with iPhone development you can add view’s to UIWindow, which stays there irrespective of which UIViewController is currently active. I want exact behavior in my application.

My original setup

I am targeting android 2.1 and above. It seems Fragment is available from API level 11 (android 3.0) and above. One option is to use android compatibility library that enables usage of Fragment in older versions. I am currently researching on that now. But I also would like to know if there is any other methods available to fulfill my requirement, rather than change my entire project and use fragments.

I have around 30 odd activities in my application and I want this layout floating over all of them. I just made out a test case with 2 activities to make the question simple and easy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:40:00+00:00Added an answer on June 5, 2026 at 11:40 pm

    Solution 1: FrameLayout

    I think what you want to use is the FrameLayout. FrameLayout is designed to block out an area on the screen to display a single item. Child views are drawn in a stack, with the most recently added child on top.

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

    Then read here about the back stack that you could use in your activity to flip back and forth between the activities using the back button:

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

    Solution 2: Fragment Transactions

    Rather than code two separate Activities, code a single Activity with two Fragments. Here is a blurb from the Fragments documentation:

    “A fragment must always be embedded in an activity and the fragment’s lifecycle is directly affected by the host activity’s lifecycle. For example, when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all fragments. However, while an activity is running (it is in the resumed lifecycle state), you can manipulate each fragment independently, such as add or remove them. When you perform such a fragment transaction, you can also add it to a back stack that’s managed by the activity—each back stack entry in the activity is a record of the fragment transaction that occurred. The back stack allows the user to reverse a fragment transaction (navigate backwards), by pressing the Back button.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have a application requirement in Android. In my application I want to add
I have a requirement in my application where we have to perform certain activities
For my ipad application i have requirement like this For each row in root
While developing my WordPress application i have a requirement where i need to show
I am using Asp.Net/C# in my application,I have a requirement where I need to
I have following requirement in my application. A tableView with games title After selecting
I have a requirement to design a Web Application which acts as a Facade
I have a requirement in my MVC application to present the user with a
I have a Requirement to make an IMAP client as a Web application I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.