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

  • Home
  • SEARCH
  • 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 7034663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:12:48+00:00 2026-05-28T01:12:48+00:00

I am trying to add ImageView programatically inside a LinearLayout, which has vertical orientation.

  • 0

I am trying to add ImageView programatically inside a LinearLayout, which has vertical orientation. My layout file is describe as the xml below:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:paddingTop="5dip"
   android:id="@+id/mainView"">

   <TextView android:id="@+id/tvTituloInformacao"
    android:layout_width="fill_parent"          
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:textStyle="bold"
    android:textColor="@color/white"
    android:gravity="center_horizontal"
    android:shadowColor="@color/black_translucent"
    android:shadowDx="2.0"
    android:shadowDy="2.0"
    android:shadowRadius="3.0"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true" /> 

    <LinearLayout android:id="@+id/resourceContainer"
    android:layout_width="fill_parent"          
    android:layout_height="wrap_content"
    android:layout_marginTop="5dip"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip"
    android:layout_marginBottom="10dip"
    android:padding="3dip"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:layout_below="@+id/tvTituloInformacao"
    android:background="@color/black_translucent2" /> 

 </RelativeLayout>

And my java source code that adds the ImageViews to the LinearLayout is as follow:

for(Resource r : mUser.getPictures()) {
    ImageView img = new ImageView(this);
    img.setVisibility(View.VISIBLE);
    img.setTag(r.getThumb60());
    imageLoader.DisplayImage(r.getThumb60(), this, img);
    ((LinearLayout) tempFotosView.findViewById(R.id.resourceContainer)).addView(img);
}

What happens is that before and after each ImageView I am getting some extra spaces that should not be there, so the height of the images container increases a lot. One test that I did and got the expected result was not to use the imageLoader and instead I set the ImageResource programatically to a static image file. This way I didn’t get any extra space.

The weird result is illustrated in the image below:

enter image description here

Is there a way to not add this extra space?

  • 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-05-28T01:12:49+00:00Added an answer on May 28, 2026 at 1:12 am

    I think images you are loading in image views may have some extra spacing on top and bottom, and other assumption you are loading images in imageview, with different resolution than your screen-size, and setting scaleType of ImageView to centerInside, if it is the case please try using following by fixing height of the image view as well, and set scaleType to fixXY.

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

Sidebar

Related Questions

I have LinearLayout in my xml file that I am trying to add a
I'm trying to add a custom ImageView to my main.xml , but if I
Im trying to add some short file names to a Wise installer to fix
I am trying to add an image to the UIBarButtonItem which I have to
I am trying to add animation for UIImages which are added in an array.
I am trying to display a jpg file from a server into an imageView.
I have a ListActivity in which I am trying to display an ImageView under
Im trying to add a textview to a linear layout progmmatically, but I keep
I'm trying to add thumbnails into cells in UITableView cell.imageView.image = [UIImage imageNamed: @TestThumbnail.jpg];
I'm trying to download an image, and create an ImageView dynamically and add it

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.