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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:11:55+00:00 2026-06-08T12:11:55+00:00

The idea is to either display a photo or – if none is defined

  • 0

The idea is to either display a photo or – if none is defined – a small icon symbolizing it.

I have defined the following ImageView in the layout:

        <ImageView
            android:id="@+id/imgPic"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:contentDescription="@+string/strImgPic"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:saveEnabled="false"
            android:src="@drawable/pic_icon" />

So the ImageView is pre-initialized with the ‘icon’ PNG.

The code to load it:

try {
imgURL = vinfo.getString("mainpic_url");
    if (imgURL.length() > 1) {
   imgURL = getString(R.string.urlPicsFull) + imgURL;
   ImageView imgPic = (ImageView) findViewById(R.id.imgPic);
   ImageDownloader img = new ImageDownloader();
   img.download(imgURL, imgPic);
    }
 } catch (..) {
(..)

ImageDownloader() basically does nothing else than retrieving the image asynchronously. The problem however is that if there is NO image ( imgURL.length()==0 ) , the icon is displayed with a very large ‘border’ in the middle of an empty square in the layout.

I would like the image to be scaled down (or up) to the width of the parent view, but the icon to display as it is (about 90 dip wide and high).

Any suggestion on how to realize that?

  • 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-08T12:11:57+00:00Added an answer on June 8, 2026 at 12:11 pm

    Check out the android:scaleType tag of the ImageView. For your case if you add

    android:scaleType="fitXY"
    

    in your ImageView definition in the layout, and the image will be adjusted to your ImageView size. Something like this:

    <ImageView
            android:id="@+id/imgPic"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:contentDescription="@+string/strImgPic"
            android:paddingRight="10dip"
            android:scaleType="fitXY"
            android:paddingTop="10dip"
            android:saveEnabled="false"
            android:src="@drawable/pic_icon" />
    

    However this will not maintain the aspect ratio so the image may be distorted. If you do not want that, check the other values that the android:scaleType tag can take in the link provided.

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

Sidebar

Related Questions

I have $ad_text=wordwrap(nl2br($_POST['annonsera_text']), 45, '<br />\n'); Any idea why the above does display in
Idea: I want to make smth like real time electronic blackboard. Many users have
The idea is the following. I send some text to jinja2 using tags similar
i have no idea how to get these errors out. i wrote the whole
I have thought about this for a while - not getting a good idea.
I'm new to Android, I've followed the hello world tutorial through and have a
I have a section on a website where you click a div to display
Note: In some situations elements with display:table-cell; have space at the top that is
I want to have display-only fields to render data that's never going to be
So, I am really balls confused here. I have no idea what I'm doing,

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.