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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:23:12+00:00 2026-06-05T11:23:12+00:00

I have an image that is 8 mp but it can’t be displayed on

  • 0

I have an image that is 8 mp but it can’t be displayed on an ImageView because it is too large of a file. How can I re-size it with a BitmapFactory and then pass this new image as the source of ImageView in the XML?

my XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/select"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Select" />

    <Button
        android:id="@+id/info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Info" />

</LinearLayout>

<ImageView
    android:id="@+id/test_image_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />


</LinearLayout>

My Activity:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ImageView view;

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize=8; //also tried 32, 64, 16
    Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher, options);
    Drawable d = new BitmapDrawable(bmp);

    view = (ImageView) findViewById(R.id.test_image_view);
    view.setImageDrawable(d);

    setContentView(R.layout.main);


}
  • 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-05T11:23:15+00:00Added an answer on June 5, 2026 at 11:23 am

    You can’t pass it into XML

    For what? Load it, when you need it.
    In your case it’s better to use BitmapFactory.Options:

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize=16; //image will be 16x smaller than an original. Note, that it's better for perfomanse to use powers of 2 (2,4,8,16,32..).
    Bitmap bmp=BitmapFactory.decodeSomething(..., options) //use any decode method instead of this
    Drawable d=new BitmapDrawable(bmp);
    

    and then just set it to your ImageView

    ImageView iv; //initialize it first, of course. For example, using findViewById.
    iv.setImageDrawable(d);
    

    Note, that you should recycle your bitmap, after you used it (after ImageView is not visible anymore):

    bmp.recycle();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have image map that can I move, but this map will be so
I have an image that is served as static file using Nginx, but I
I have a circle image that's fairly large in size to make it easy
I have an image that need to be removed, but I can't have access
I have this background image that is 175x175 but I am trying to make
I have an image upload function that supports multiple files upload, but somehow it
So I have a tiny header image that repeats on the x axis, but
I have an image, that has transparent areas and a known backround. But wheh
i have created one image but problem is that when i save image from
I want to have a UIView subclass that has a border image, but I

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.