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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:42:24+00:00 2026-06-09T12:42:24+00:00

I am making an android App in which the user picks and loads a

  • 0

I am making an android App in which the user picks and loads a image from the gallery. I am done with loading my image in an image view. There is a button above the image view. When the user clicks the button a rectangle has to be drawn on the image with default position and dimensions. The user can re-size this rectangle by clicking on the sides and also drag the rectangle to any point in the image view. I did some research on Google and stack overflow to find that I need to create a custom view for my rectangle and draw it over the imageview. The solutions that I found have shown how to make a custom view and how to add touch events to that. But the problem is I didn’t find a solution to how to add myCustomView on the image view in an activity. Please help me clearing this doubt.

Below is my main activity on which there is a button (Load Image) User clicks on it to load an image from the gallery. The path of the image is sent to the other activity.

public class MainActivity extends Activity {
    private static int RESULT_LOAD_IMAGE = 1;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button buttonLoadImage = (Button) findViewById(R.id.buttonLoadPicture);
    buttonLoadImage.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            Intent i = new Intent(
                    Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

            startActivityForResult(i, RESULT_LOAD_IMAGE);
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK
            && null != data) {
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };

        Cursor cursor = getContentResolver().query(selectedImage,
                filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String picturePath = cursor.getString(columnIndex);
        cursor.close();
        Intent i = new Intent(MainActivity.this, ImageActivity.class);
        i.putExtra("key", picturePath);
        startActivity(i);
        finish();

    }
}
}

Below is the activity where the image is displayed on the imageview and the mycustomview has to be called.

public class ImageActivity extends Activity {
 Paint paint = new Paint();


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image);

    Bundle bundle = getIntent().getExtras();
    final String value = bundle.getString("key");
    Bitmap bmp = BitmapFactory.decodeFile(value);
    ImageView imageView = (ImageView) findViewById(R.id.imgView);
imageView.setImageBitmap(bmp);


    Button buttonExit = (Button) findViewById(R.id.buttonExit);
    buttonExit.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            finish();
        }
    });

    Button buttonDrawRect = (Button) findViewById(R.id.DrawRect);
    buttonDrawRect.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {


        }
    });
}

enter image description here

  • 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-09T12:42:26+00:00Added an answer on June 9, 2026 at 12:42 pm

    Go through these links. May help you

    Overlapping Views in Android

    How to add overlay view over other view in android?

    Also check the linked posts also

    Hope this may help you

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

Sidebar

Related Questions

I am making an android database app in which when i fetch values from
I am making an Android app which requires a main view with similar functionality
I'm making an Android app where the user can download files from a FTP-server.
I am making an android app in which the user needs to add information.
I am making an android app in which i am trying to slide between
I'm making a Android app that basically plays video from a website on the
i am making a app which takes photo on button click i have camera.java
I am making an android app in which i have to show Hash Tag
I am making an android app in which I am trying to lazyload and
I am making an android app in which I need to make different tables

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.