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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:14:05+00:00 2026-06-05T08:14:05+00:00

When I use android:adjustViewBounds=true in my imageView xml, it does not function. If I

  • 0

When I use android:adjustViewBounds=”true” in my imageView xml, it does not function. If I put setAdjustViewBounds(true); in the constructors of my ImageView, it works fine. What is the difference, or is this a bug?

<ImageView
                android:id="@+id/PageViewMainImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="matrix"     
                android:adjustViewBounds="true"               
                android:visibility="invisible"/>
  • 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-05T08:14:06+00:00Added an answer on June 5, 2026 at 8:14 am

    The order of operations in the ImageView constructor (see source here) parses out and sets the adjustViewBounds property from XML before it parses and sets the scaleType attribute from XML. Part of the setAdjustViewBounds() method (which is called by the constructor with your XML attribute value) is to set the ScaleType to FIT_CENTER when the value is true.

    So when the XML you posted is loaded, the ScaleType is first set to FIT_CENTER and then re-set to MATRIX afterwards, all inside the constructor. Compare this with your example of calling setAdjustViewBounds() in Java instead, and now the final ScaleType will be FIT_CENTER as your Java call will happen after the XML attributes are parsed (effectively meaning that your android:scaleType="matrix" attribute is ignored. That difference is likely what you are seeing between “works” and “doesn’t work”.

    I’m not sure if Google would call it a bug, as they are only setting the ScaleType to what they think you want as a convenience to preserve the aspect, but still allow you to modify this. The bounds of the view themselves will still change as the property name directs, the image just may clip in a way you didn’t expect.

    The docs could probably be more clear on this “feature” though, so you could file a bug report at http://b.android.com

    HTH

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

Sidebar

Related Questions

When should we use android:clickable in XML? Should we ever? Is there any difference
How can I make use of android.grapics.color constants? http://developer.android.com/reference/android/graphics/Color.html This does not work: android:drawable=@android:color/cyan
The tutorial says to use android.appwidget.action.APPWIDGET_UPDATE in the action element within the XML intent-filter
I can use android:gravity=bottom|center_horizontal in xml on a textview to get my desired results,
I was wondering why not use android:configChanges=keyboardHidden|orientation in every (almost every ;)) activity? Goods:
I'm trying to use Android's animation framework to have my ImageView move in a
I've seen several examples that use android:layout_height=0px or 0dip but i do not understand
I use android:imeOptions=actionSend or android:imeOptions=actionDone in xml for Edittext. Send or Done key is
I'm trying to use android-opencv 2.3.1 to recognize circles (coins) in an image. However
Can I use Android's sharedpreferences to pass a Java object between different activities?

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.