03.12.2010 19:37, Serdel пишет:
Thanks Vasilyev,

It's "Kostya" (V. is my last name).

The aspect ration is in deed a very important factor - I was surprised
why my layout looks fine in eclipse plug in but corrupts on the
device. Only when I design my own dev config with proper size and
ratio as long it worked correct. I now have a quite similar problem.
Because I have design some images for the background of my buttons (I
use button not imagebuttons to avoid the white 'frame' around the
image). However the images are bigger than I expected them to be.
Using my example - images for B1 and B2 (despite being 240px long) are
much longer than the half of the screen.

If they are in res/drawable, they are considered "mdpi" images (for 320 by 480 screen size, etc).

If your emulator is higher-res (typical for 480 by 800, etc.), then Android will scale those images at load time, by a factor of 1,5 (hdpi is 240 pixels per inch, mdpi is 160 pixels per inch).

You should carefully read through "multiple screen support" link you referred to in your previous email to understand image resource scaling.

Then I'd recommend you make your layouts work at default resolution & density (320 by 480, medium screen density) and only then move onto high-density and high-resolution screens.

If I place them with relative
layout they overlap. If I switch to linear layout with weigth 1 the
width is adjusted properly however the height stays the same (I need
to set it manually which I would like to avoid). Can I somehow do it
so the image would resize both its dimensions automatically to keep
it's previous ratio? So that If I fit the images with linear layout
their height would also shrink due to 'forced' shorted width?
You could use ImageView, it has a lot of flexibility for image scaling and resizing:

http://developer.android.com/reference/android/widget/ImageView.html

In particular, take a look at these settings: adjustViewBounds, cropToPadding, scaleType.

You can set a click listener on an ImageView, and can implement visual feedback for when it's touched by using a state-list drawable with state_pressed:

http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

-- Kostya

--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to