Ideas for getting pictures to stay there same proportions .


Last Updated:

  1. sambocrockett

    sambocrockett Member This Topic's Starter

    Joined:
    Jun 8, 2010
    Messages:
    22
    Likes Received:
    1
    Ive been working on getting images to load from the res file to screen and stay their same proportions no matter what the screen size. The problem Im having is that the images stretch to fit the screen and I cant seem to get them to stay in proportion. Ive looked through the sdk notes but havent really found anything that I can understand how to implement. The app I am working on basically just takes pictures stored in the res file and draws them to the screen and has two buttons to scroll back and forth through the pics.....its just for my own practice for now but I plan on implementing more into it once I get a better handle on android development.

    Anyway, I got the pictures to draw to screen but the problem Im having is that the pictures are stretching to fit the screen.

    Any thoughts on how I can get the pics to not stretch and stay in proportion from platform to platform.
     

    Advertisement
  2. cp1

    cp1 Well-Known Member

    Joined:
    Apr 30, 2010
    Messages:
    375
    Likes Received:
    35
    I'm not sure if you can do it if you're still using setBackgroundDrawableResource

    If you switch to using an imageview it looks like there are a few settings that might work:
    ImageView | Android Developers

    android:adjustViewBounds setAdjustViewBounds(boolean) Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable. android:cropToPadding
    If true, the image will be cropped to fit within its padding. android:maxHeight setMaxHeight(int) An optional argument to supply a maximum height for this view. android:maxWidth setMaxWidth(int) An optional argument to supply a maximum width for this view. android:scaleType setScaleType(ImageView.ScaleType) Controls how the image should be resized or moved to match the size of this ImageView.
     
    sambocrockett likes this.
  3. sambocrockett

    sambocrockett Member This Topic's Starter

    Joined:
    Jun 8, 2010
    Messages:
    22
    Likes Received:
    1
    Cool :) thanks again man.....I'm very new to java, xml, and objective c programming and but I have a little c++ and C# experience so I can kind of make a connection some times.....but usually Im just totally lost.....but thanks again :)
     

Share This Page

Loading...