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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:46:10+00:00 2026-06-14T11:46:10+00:00

The code is simple: <ImageView android:layout_width=fill_parent android:layout_height=fill_parent android:src=@drawable/cat/> Notice the ImageView used fill_parent for

  • 0

The code is simple:

<ImageView android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:src="@drawable/cat"/>

Notice the ImageView used fill_parent for width and height.

The image cat is a small image and it will be zoomed in to fit the ImageView, and keep the width/height ratio at the same time.

My question is how to get the displayed size of the image? I tried:

imageView.getDrawable().getIntrinsicHeight()

But which it the original height of the image cat.

I tried:

imageView.getDrawable().getBounds()

But which returns Rect(0,0,0,0).

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

    the following will work:

    ih=imageView.getMeasuredHeight();//height of imageView
    iw=imageView.getMeasuredWidth();//width of imageView
    iH=imageView.getDrawable().getIntrinsicHeight();//original height of underlying image
    iW=imageView.getDrawable().getIntrinsicWidth();//original width of underlying image
    
    if (ih/iH<=iw/iW) iw=iW*ih/iH;//rescaled width of image within ImageView
    else ih= iH*iw/iW;//rescaled height of image within ImageView
    

    (iw x ih) now represents the actual rescaled (width x height) for the image within the view (in other words the displayed size of the image)


    EDIT: I think a nicer way to write the above answer (and one that works with ints) :

    final int actualHeight, actualWidth;
    final int imageViewHeight = imageView.getHeight(), imageViewWidth = imageView.getWidth();
    final int bitmapHeight = ..., bitmapWidth = ...;
    if (imageViewHeight * bitmapWidth <= imageViewWidth * bitmapHeight) {
        actualWidth = bitmapWidth * imageViewHeight / bitmapHeight;
        actualHeight = imageViewHeight;
    } else {
        actualHeight = bitmapHeight * imageViewWidth / bitmapWidth;
        actualWidth = imageViewWidth;
    }
    
    return new Point(actualWidth,actualHeight);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have write this code to move a simple ball with an ImageView
I have simply extended the ImageView so an image goes full width. Like so:..
Today I'm working with an interesting problem. I'm trying to code simple bookmarks, and
Some simple code: - (IBAction)Up_Down:(UIStepper *)sender { double value = [sender value]; [NumDayLabel setText:[NSString
Simple code: #include <signal.h> #include <stdio.h> #include <unistd.h> #include <iostream> using namespaces td; bool
The simple code block below can be served up in a static HTML page
Simple code indeed : int number = int.MaxValue; number = number+1; Console.WriteLine(number); Questions :
The following simple code pattern is very common in graphics programming. It creates an
here my simple code to add filename and their associated icon to virtualtreeview PFileInfoRec
This very simple code: #include <iostream> using namespace std; void exec(char* option) { cout

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.