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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:55:16+00:00 2026-06-12T12:55:16+00:00

I have a requirement of loading an Image from a URL in my Android

  • 0

I have a requirement of loading an Image from a URL in my Android application

For this I created an ImageView in my layout. Following is the Imageview

<ImageView
    android:id="@+id/MyImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:layout_gravity="center_horizontal">          
</ImageView>

And then in my code I use the following to load the image in this ImageView

ImageView bmImage = (ImageView)this.findViewById(R.id.MyImage);
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
    InputStream in = new java.net.URL(urldisplay).openStream();
    mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
    Log.e("Error", e.getMessage());
    e.printStackTrace();
}

bmImage.setImageBitmap(mIcon11);

The image that is lying on my URL path is of size 320 X 50. But very strange, when the image is shown in the ImageView, the size becomes very small, almost half the width and height

I have tried a lot but no solution. Can anybody help please?

  • 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-12T12:55:18+00:00Added an answer on June 12, 2026 at 12:55 pm

    I think the problem is that you are setting bitmap pixels and expecting device pixels

    Try to get the density of the screen then set the width/height so it stretches accordingly, like this:

    ImageView bmImage = (ImageView)this.findViewById(R.id.MyImage);
    String urldisplay = urls[0];
            Bitmap mIcon11 = null;
            try {
                InputStream in = new java.net.URL(urldisplay).openStream();
                mIcon11 = BitmapFactory.decodeStream(in);
            } catch (Exception e) {
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }
    
     bmImage.setImageBitmap(mIcon11);
     if(mIcon11 != null){
       int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mIcon11.getWidth(), this.getResources().getDisplayMetrics());
       int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mIcon11.getHeight(), this.getResources().getDisplayMetrics());
    
       bmImage.setMinimumWidth(width);
       bmImage.setMinimumHeight(height);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to play YouTube video content from within an Android application
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
For my ipad application i have requirement like this For each row in root
We have a WPF application that is loading a usercontrol at runtime from the
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I
In our project we have requirement that, after receiving sms message from third party
We have a requirement that a user can load any standard image into a
I have used to loading a default image in my appication. So i have
i'm working on an attendance program and i have this requirement to be able
Let's understand the my requirement / question. I have to develop following things in

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.