0

I am working on an Android application and since I am a beginner in Android development, I have a difficulty about designing my UI.

The UI consists of many images which acts as small widgets on the screen. I want that these images to always cover a certain portion of the screen, such that the layout is compatible with different devices of different screen sizes. For example, I have a panel, which I want to be aligned with the top edge of the screen and cover %30 of the screen beginning from the top edge. I know that I am able to achieve this by mixing Relative and LinearLayouts appropriately in the layout xml, but what I fail is to make an image I am putting into an ImageView resize according to the ImageView's size on the screen. In my case it seems that the ImageView itself resizes itself according to the image I am putting in it. In other words, if I have an ImageView object which covers the upper %30 of the screen, I want it to remain the same after I put an image into it. (The image may be distorted a little, it is not much a concern for me in this case).

Ufuk Can Bicici
  • 3,589
  • 4
  • 28
  • 57
  • Can you put some code ? – Mehdi Mar 14 '13 at 09:55
  • There is question in stack overflow which deals with this issue. [Click here][1] [1]: http://stackoverflow.com/questions/2521959/how-to-scale-an-image-in-imageview-to-keep-the-aspect-ratio – Premsuraj Mar 14 '13 at 09:59

1 Answers1

0

First of all, for Android SDK there is guideline available to create an app for different screen size. Follow this: http://developer.android.com/guide/practices/screens_support.html

If you want to have a view, which appears with specific amount of area like 30% or 80%, you can use android:layout_weight attribute in the layout instead of defining the specific height or width.

If you want your image will always fill the ImageView, you should use android:scaleType="fitXY" attribute within your ImageView.

shaonAshraf
  • 1,107
  • 1
  • 11
  • 21