• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Ideas for getting pictures to stay there same proportions .

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.
 
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.
 
  • Like
Reactions: sambocrockett
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones