0

I'm a computer science student and a beginning Android developer, learning on the job. My boss, a small business owner, paid another programmer to create an iOS app. Now he's paying me to create the Android version. He sent me the image assets used for buttons and backgrounds. The app mostly displays text, and it has a textured background from an image.

Because iOS has only a few screen sizes, it was relatively easy for them to create a background image for each screen size.

I'd like to be able to have the same background, but the logistics are more complex with Android.

My proposed solution dynamically cut out a screen size image from a larger image, and make it the background.

My plan was to crop the larger image to screen size with a Bitmap file, and then set it the main screen in onCreate(). This S.O. post gave me the idea to do that.

I was wondering if anyone has tried this before?

Could this be a good solution?

Also:
1) How can I dynamically obtain the screen size, to determine the correct size of the background image?
2) What units should I use for cropping the Larger image? When I use
createBitmap(Bitmap source, int x, int y, int width, int height) what should be the unit for width and height?

+----------------------------------------+  
| x x x x x x x x x x x x x x x x x x x x|
|x x x x x x x x x x x x x x x x x x x x |
| x x x x x x x x x x x x x x x x x x x x|
|x x x x x x x x x x x x x x x x x x x x |
| x x x x x x +--------------------------+                           
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|    
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|   
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|    
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|  
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|    
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|   
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|    
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|  
|x x x x x x x|x x x x x x x x x x x x x |
| x x x x x x | x x x x x x x x x x x x x|     
+----------------------------------------+
Community
  • 1
  • 1
Timothy Steele
  • 773
  • 1
  • 7
  • 19
  • http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels – Mstack May 21 '15 at 09:00
  • You want to repeat the background so it fits to button background or just want to scale down of an image that you've in asset according to buttons ? – MrDumb May 21 '15 at 10:14
  • @ashutiwari4 I want to scale down an image and set it as the background. The large box of x's I illustrated represents a textured background – Timothy Steele May 21 '15 at 17:12

0 Answers0