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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:26:27+00:00 2026-06-12T20:26:27+00:00

I have a custom view class (a canvas for drawing). When I want it

  • 0

I have a custom view class (a canvas for drawing). When I want it to take up the whole screen, I instantiate the class and call setContentView like so:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        drawingPanel = new DrawingPanel(this);
        setContentView(drawingPanel);
}

However, when I want the screen to be base on an xml layout (activity_make.xml) with say 2 elements, one button and a placeholder for the drawing canvas, how do ‘stick’ my custom view into the view placeholder?

public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_make); // the layout which has a button and a placeholder view
      drawingPanel = new DrawingPanel(this); // instantiating my canvas
      View drawPanelPlaceholder = (View) findViewById(R.id.drawingview);
      // how do i stick the drawingPanel into the drawPanelPlaceholder?
}

Or is there a better way to approach this? Links to documentation regarding this are also appreciated!

  • 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-12T20:26:29+00:00Added an answer on June 12, 2026 at 8:26 pm

    If your DrawingPanel class extends View you can do something like this,

    In your xml declare this custom component with its package name,

    <com.myview.DrawingPanel android:id="@+id/drawingview" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" >
    

    Please note that, com.myview.DrawingPanel is just a name that I have used to demonstrate. But make sure you use the same package name in which you have your DrawingPanel.class.

    And now in your onCreate,

    public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_make); 
          drawingPanel = (DrawingPanel) findViewById(R.id.drawingview);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom view: public class Loading extends View { private long movieStart;
I have a custom-made view that extends the View class. I would like 2
I have a class for my custom view. One of methods is @Override public
friends, i have a custom view class public class Zoom extends View { private
Currently I have a custom view: public class MyView extends View { public MyView(Context
I have a custom view which is extending View : public class MyView extends
We have a screen and its view model: public class ScreenViewModel : BaseViewModel {
i have prepared one custom view using onDraw method, my view class is, public
I have a custom drawing drawn on a custom view .I would like to
I have a custom View that I would like to embed in an WebView.

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.