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 3786800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:44:24+00:00 2026-05-19T11:44:24+00:00

How do I set some UI elements over (on top of) canvas? I have

  • 0

How do I set some UI elements over (on top of) canvas?

I have a simple touch game that has its graphics placed on custom view with canvas. However as my full screen Panel is in the setContentView() I can’t add any UI items like progressBar or logo. I would like to have whole canvas layer visible with some objects (progressBar, logo) “floating” over it.

Main class:

public class GameClass extends Activity implements OnGestureListener {

Panel panel;

public void onCreate(Bundle savedInstance) {
  super.onCreate(savedInstance);

  panel = new Panel(this, 1, 2);
  setContentView(Panel);
  ...
}

Panel class:

public class Panel extends View {   

  public Panel(Context context, int Var1, int Var2) {
    super(context);
    ...
  }

  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    ...
  }
}

As code shows, touches are handled inside GameClass and the changes in animation are handled inside Panel.

Or maybe.. Would it be possible to start new transparent activity with progress bar and button so that both the button on overlay activity AND objects on underlying activity? And I could need a way to close all the layers (transparent activity, Panel, GameClass) with the button on transparent activity. Complicated? 😀

  • 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-05-19T11:44:24+00:00Added an answer on May 19, 2026 at 11:44 am

    I do have the same problem and here is how I solved it

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.game);
    
        drawView = new DrawView(this);
        drawView.requestFocus();
        LinearLayout upper = (LinearLayout) findViewById(R.id.LinearLayout01);
        upper.addView(drawView);
        ImageButton menu = (ImageButton) findViewById(R.id.ImageButton01);
        menu.setOnClickListener(new OnClickListener()
        {           
            @Override
            public void onClick(View v)
            {
                finish();
            }
        });
        ImageButton reset = (ImageButton) findViewById(R.id.ImageButton02);
        reset.setOnClickListener(new OnClickListener()
        {           
            @Override
            public void onClick(View v)
            {
                drawView.resetGame();
            }
        });
    }
    

    instead of setting contentview to panel adding it Linearlayout that is added in my game.xml and here goes my

    game.xml

    <?xml version="1.0" encoding="utf-8"?><RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:background="@drawable/game_background">
    <LinearLayout
        android:id="@+id/LinearLayout01"
        android:layout_width="fill_parent"
        android:layout_height="350dip" />
    <LinearLayout
        android:id="@+id/LinearLayout02"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/LinearLayout01">
        <ImageButton
            android:id="@+id/ImageButton01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/menu"></ImageButton>
        <ImageButton
            android:id="@+id/ImageButton02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/reset"></ImageButton>
    </LinearLayout>
    <LinearLayout
        android:layout_below="@+id/LinearLayout01"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:id="@+id/layout_ad"
        android:layout_height="wrap_content" />
    

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

Sidebar

Related Questions

I've implemented a set of draggable elements that can be dropped into some containers
I have a block element that is positioned absolutely and some other elements on
I have an WPF usercontrol that has a TextBox. I set the text Underline
I wanted to set some handler for all the unexpected exceptions that I might
I'm trying to write a shell script that, when run, will set some environment
I have an animation that I have setup on a transparent Canvas . I
I have a 1px wide by 35px high image, that I set as background
I would like to iterate over a Set and remove the elements from the
I have managed to get myself confused about some elements of memory management. I
Background: I have a window that starts out with a width of 240px, some

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.