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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:28:09+00:00 2026-06-14T17:28:09+00:00

When I click the button,call drawDigit(),puzzleview is only a LinearLayout in Activity protected void

  • 0

When I click the button,call drawDigit(),puzzleview is only a LinearLayout in Activity

protected void drawDigit(Canvas canvas, int digit) {
        // TODO Auto-generated method stub
        if(num < diff){
            int x = tiles.get(num).getScrollX();  // get the X coordinate of ImageView,it's 0
            int y = tiles.get(num).getScrollY();  // get the Y coordinate of ImageView,it's 0
            float height = tiles.get(num).getHeight(); // height is 0
            float width = tiles.get(num).getWidth();   // width is 0
            background.setTextSize(height * 0.75f);
            background.setStyle(Style.FILL);
            background.setTextScaleX(width/height);
            background.setTextAlign(Paint.Align.CENTER);
            canvas.drawText(digit + "", x, y, background);
            //num++;
        }
    }

How can I assign the ImageView in Layout to tiles,then get the coordinate and size?

  • 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-14T17:28:11+00:00Added an answer on June 14, 2026 at 5:28 pm

    You can try this :

    //This is for Getting ImageView size that is fixed in layout

    int imageHeight;
    int imageWidth;
    
    ImageView imageViewObj = (ImageView)findViewById(R.id.image_view_id);
    ViewTreeObserver treeObsObj = imageViewObj.getViewTreeObserver();
    treeObsObj.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
    
        public boolean onPreDraw() {
        imageWidth= imageViewObj.getMeasuredWidth();
        imageHeight = imageViewObj.getMeasuredHeight();
        return true;
    }
    });
    

    // Getting the size of the Image inside the ImageView and The size will differ based
    **// on the image you placed inside the ImageView

    ImageView imageObj = (ImageView)findViewById(R.id.image_view_id);
    int imageWidth = imageObj.getWidth();
    int imageHeight = imageObj.getHeight();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

click the button to call this method: private void goRegister(final boolean isUsername) { new
i have an activity that displays two buttons , on click of call button
How to call multiple functions on button click event? Here is my button, <asp:LinkButton
I have a button click on which i have to call a webmethod and
I want to call a html page on click of a button in mvc.
I create ASP .NET MVC application. On button click I call JavaScript that disable
May be a simple question to solve... On button click I call a function
I wanna know that how to call JFrame from jsp. When I click button
Possible Duplicate: Call PHP function from jQuery? Jquery on button click call php function
I need to know if it's possible to call the Click of a button

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.