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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:53:47+00:00 2026-05-31T04:53:47+00:00

I am designing an android application contain MySurfaceView includes a Canvas to draw images

  • 0

I am designing an android application contain MySurfaceView includes a Canvas to draw images in a thread running through the application,

(layout is default main.xml which create with project)

but i have to add a bar/textView in the top and add an AD in the botton of the screen.
then how can i do this ?

my declaration is like this :

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

    mySurfaceView = new MySurfaceView(this);
    setContentView(mySurfaceView);              
}

May be my given information is not enough to understand the situation, so if you find any obscurity in my question please ask me

Thanks in advance

  • 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-31T04:53:49+00:00Added an answer on May 31, 2026 at 4:53 am

    Hmm, one possibility is that you could just put it inside of a RelativeLayout or something similar? This assumes that you don’t want to just define it in the xml which would probably look cleaner. The code would probably look something like this (you can definitely make it more efficient/just use a LinearLayout, I just threw down the first thing that came into my head):

      RelativeLayout layout = new RelativeLayout(this);
      RelativeLayout.LayoutParams paramsTop =
              new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
                                              RelativeLayout.LayoutParams.WRAP_CONTENT);
      // Add the textView to the top
      paramsTop.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    
      TextView textView = new TextView(this);
      textView.setText("Hello World");
      // Give them id's since we need to position relative to one another
      textView.setId(1);
      layout.addView(textView, paramsTop);
    
    
      AdView adView = new AdView(this, AdSize.BANNER, INSERT_ADMOB_ID_HERE);
      adView.setId(2);
      RelativeLayout.LayoutParams paramsBottom =
          new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                          RelativeLayout.LayoutParams.WRAP_CONTENT);
      // Add the adView to the bottom
      paramsBottom.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    
      layout.addView(adView, paramsBottom);
      AdRequest adRequest = new AdRequest();
      adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
      adView.loadAd(adRequest);
    
    
      SurfaceView view = new SurfaceView( this );
      view.setId(3);
      RelativeLayout.LayoutParams paramsMiddle =
              new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
                                              RelativeLayout.LayoutParams.WRAP_CONTENT);
    
      // Add the surfaceView in between the textView and the adView
      paramsMiddle.addRule(RelativeLayout.BELOW, textView.getId());
      paramsMiddle.addRule(RelativeLayout.ABOVE, adView.getId());
      layout.addView(view, paramsMiddle);
    
      setContentView(layout);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing an Android application which will be displaying some news that will
I am working on designing an Android application, and I have several questions I
I am currently designing a native android application. I am planning to use jQuery
I'm designing an Android app which loads lots of small (say 128x128px@24-bit) PNG images
I'm in the process of designing an Android application right now. I understand SQLite
I am a newbie in Android and currently I am designing an application where
I am designing an application based on android platform. I want to show Right
As part of my final year project, I'm designing an Android application that needs
I am new to Android layout development and have been tasked with designing and
i am working in android. i am designing an application which is based on

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.