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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:34:51+00:00 2026-05-27T06:34:51+00:00

I want to make three images randomly appear on screen at certain position in

  • 0

I want to make three images randomly appear on screen at certain position in android.
And I want to make those images clickable. If you click on a single image which is appeared the counter will be increased by one.
How do I go about it??

  • 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-27T06:34:51+00:00Added an answer on May 27, 2026 at 6:34 am

    You can draw an image on a Canvas using following code.

    Rect dst = new Rect(x, y, x + imageWidth,y + imageHeight);
    
    //enter paint as the last arg to use bitmap filtering
    canvas.drawBitmap(myBitmap, null, dst, bitmapFilterSettings);
    

    myBitmap is a Bitmap, bitmapFilterSettings is a Paint. Place this code in your onDraw() method.

    In order to place the image randomly, you have to randomize the x and y you pass to the dst Rect. In order to select a random image, you can put you Bitmaps in a List or an array and use the nextInt(listSize) method of Random. In order to make the image appear and disappear randomly, use the nextBoolean() method of Random and only draw the image if it returns true. Do not do this too often (once every X frames), or your image will flicker.

    EDIT : To do this you can declare a counter in the Activity and the number of frames between the decisions. You will also need a boolean field to switch drawing on and off. In your onDraw() it could look like this:

    counter++;
    if(counter%framesBetweenDecision == 0){
     drawImageFlag = random.nextBoolean();
    }
    if(drawImageFlag){
    //drawImage
    }
    

    To make the times between the decisions less predictable you could also randomize the timeBetweenDecision.

    /EDIT

    You can handle the touch event in your listener, calling the random image selection on each click. If you want to make only the image part clickable, check the location of your MotionEvent (you can use the getX() and getY() methods) to lie inside the same Rect you are using to draw you image using it’s contains(x, y) method.

    This is not the only way to achieve this, but a quite straightforward one.

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

Sidebar

Related Questions

I have three images that I want the user to move around the screen.
I want to make the textbox allow only three digits and three decimals.For example
I need to generate small images for certain parts of text. Those will have
I want to make an flipping card object which has three sides, basic requirement
I'm using a php script to randomly show images. I've duplicated this script three
I have a virtual path (example: ~/Images/Banner.jpg) and I want to make that an
I want to make an app which have one panoramic image, and when I
I have three images and I want change the images size based on the
My problem: I want to make a lot of images that differ only in
I want to make a grid with 3 images in a row and then

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.