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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:09:17+00:00 2026-06-18T16:09:17+00:00

I made a listfragment to show the imageview embedded in another fragment. By choosing

  • 0

I made a listfragment to show the imageview embedded in another fragment.
By choosing the items of the list, different images with different resolution will be shown.
But I want to make them to be shown as the same size.So this is what I did.
But with different images and resolutions, they are shown in different sizes.

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myImageView"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:scaleType="fitXY"
    android:contentDescription="@string/description"
    android:background="#FFF"
    android:padding="10dp"
    >
</ImageView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <fragment android:name="com.example.showdognames.DogImageFragment"
    android:id="@+id/DogImageFragment"
    android:layout_weight="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
  />
  <fragment android:name="com.example.showdognames.DognameFragment"
    android:id="@+id/DognameFragment"
    android:layout_weight="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
  />

</LinearLayout>
public class DogImageFragment extends Fragment {

    Integer[] imageList = new Integer[] { R.drawable.alaskan_malamute,
            R.drawable.beagle, R.drawable.border_terrier, R.drawable.dashshund,
            R.drawable.finnish_spitz, R.drawable.greyhound,
            R.drawable.portuguese_water_dog, R.drawable.rottweiler };

    private ImageView myView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        myView = (ImageView) inflater.inflate(R.layout.dog_image_fragment,
                container, false);
        myView.setLayoutParams(new LinearLayout.LayoutParams(200,200));
        return myView;
    }

    // method setImageResource is used to bound image reference array and
    // imageView
    public void update(int position) {
        if (myView != null) {
            myView.setImageResource(imageList[position]);
        }
    }

}
  • 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-18T16:09:18+00:00Added an answer on June 18, 2026 at 4:09 pm
    android:layout_weight="wrap_content" 
    

    Seriously?

    If the problem is the ImageView that not shows the image at the desired width and height you can set the android:scaleType of imageview try with fitCenter or fitXY. and see what you want to show.

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

Sidebar

Related Questions

I made a dialog with builder.setSingleChoiceItem with array of items that a user can
I hope someone can assist please. I have a Fragment hosting multiple list fragments
Made a simple script that hide/show a hidden div. The page automatically adjusts its
I made a demo of a photo concept that toggles between two images to
I made an xml layout, the layout has basically four buttons,the buttons will be
I made a list of contacts having 2 columns i.e contact name and contact
I made a tic tac toe A.I. Given each board state, my A.I. will
Made an app targeting API8 and it's running fine on all emulator images all
Made this nice little loop for hiding and showing div's, works as a charm
Made a custom obj called Item with some string fields and one float. .h

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.