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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:15:48+00:00 2026-06-15T13:15:48+00:00

I am trying to show an ImageView which is always square in shape inside

  • 0

I am trying to show an ImageView which is always square in shape inside a dialog. The dimensions may vary depending upon the resolution of the display(Width in portrait to be precise) but the ImageView is required to form the largest Square possible to accomodate a square image inside it. This is my XML code for the same.

<ImageView
    android:id="@+id/dialog_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerInside"
    android:adjustViewBounds="true"
    />

But the problem is that the Square image is set dynamically at runtime and the ImageView ends up being a rectangle with breadth as the Square Image size. What can i do to achieve the same?

EDIT: To give an idea of what i am trying to achieve is like what is shown when a contact is selected in contacts application and the profile picture is clicked. It zooms out and remains as a square on top of the activity.

  • 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-15T13:15:49+00:00Added an answer on June 15, 2026 at 1:15 pm

    Set the Image view height at run time but first get the display width with this code

    Display  display = getWindowManager().getDefaultDisplay();
    int swidth = display.getWidth();
    

    and now set the height of image view like this

    LayoutParams params = eventImage.getLayoutParams();
    params.width = LayoutParams.FILL_PARENT;
    params.height = swidth ;
    eventImage.setLayoutParams(params);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my ImageView is always trying to re-use the same bitmap whereas whenever i tap
I have a ListActivity in which I am trying to display an ImageView under
I'm trying to display an ImageView in a dialog, I've followed several examples but
I'm trying to show a MyCustomLinearLayout which extends LinearLayout . I'm inflating the MyCustomLinearLayout
I have 7 images which i'm trying to make fade in/out of 1 ImageView.
I am trying to show a progress dialog from a custom dialog while an
I am trying draw an random graph which display on imageview, I try this
I am trying to show a dialog on the click of my table row.My
i am trying to run simple JavaFx(2.0) application which will show three images as
Trying to show a label only when a certain item in a combo is

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.