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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:11:39+00:00 2026-06-14T08:11:39+00:00

I am trying to make an ImageView be a surface that I can draw

  • 0

I am trying to make an ImageView be a surface that I can draw on with my finger.

I have followed Android 2D Graphics Example, which resulted in making a whole screen drawable (with some issues, discussed in question 8287949, but somewhat disconnected from what I am trying to do.)

I am working with:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceStatA);
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    drawView = new DrawView(this);
    drawView.requestFocus();
    setContentView(R.layout.activity_main);
}

I’m thinking I need to change drawView = new DrawView(this) to something that would reference the Context of the resource I define in activity_main.xml:

ImageView
    android:id="@+id/canvasview"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/btnRed"
    android:background="@drawable/kitty"

However, I either don’t know what I’m looking for in the API reference, or I’m not finding it.

The class for DrawView is documented at Android 2D Graphics Example, so I won’t repeat it here.

I have been working through AppInventor, and trying to duplicate what I learn there in Eclipse using the real Android SDK, but I’m feeling stumped on Tutorial #1, so sorry for the newbie question!

  • 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-14T08:11:39+00:00Added an answer on June 14, 2026 at 8:11 am

    The Context used to create the View is actually the Activity so it’s already assigned to the this reference. It’s set when you call setContentView().

    Also, View#getContext().

    So to retrieve the Context you would to get a reference to the View then call getContext(). In this specific case, it would be

    ImageView img = (ImageView) findViewById(R.id.canvasview);
    Context c = img.getContext();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 7 images which i'm trying to make fade in/out of 1 ImageView.
I am trying to make an imageview that rotates while sliding across the screen.
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to make a function, which would return a RelativeLayout, with an ImageView
Greetings, I have the following layout in Android. I'm trying to make it so
I have an imageView and I am basically trying to make a thermometer style
Im trying to make a custom view that will have a dynamic number of
I have a ImageView which shows a picture that has been taken from the
I am trying to make a custom map application for Android. I have the
I'm trying make an entity with doctrine that has three associations with other entities

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.