Try giving your ImageView's layout_width/height of 0, and some weight.
Set android:scaleType as well so that the view scales the image, and not
the other way around.
http://developer.android.com/reference/android/widget/ImageView.html#attr_android:scaleType
-- Kostya
05.11.2011 17:50, quizit пишет:
I can get the image to fit the size i want by setting the height&
width explicitly but this would only look ok on certain sized
screens. Instead i want to get an image view to fit on say , half the
current screen width and 1/4 of the screens height, ie so it looks
propotional to the screen size and will look the same on most , or
all screen sizes
On Nov 5, 1:44 pm, Jeremy Dagorn<jeremy.dag...@gmail.com> wrote:
Hi,
Have you tried to play with different values available for
android:layout_width et layout_height?
Jeremy
On Nov 4, 2:15 pm, quizit<jamesfrain2...@googlemail.com> wrote:
I want to have a grid type layout of image views so I wanted to see if
I could get this using simple buttons.
This is easy enough but the problem arises when I try to use an
imageView instead of a button. Is there an easy way to force android
to fit the imageView in the exact same space a button fits in. Image
view seems to ignore the width weight? I don't mind if the aspect
ratio of the pic gets distorted but ideally it would keep this ratio
and just shrink the image till it fits exactly. What is the best way
to get this working?
Here is my current xml.......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="4">
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/chicken" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
</LinearLayout>
--
Kostya Vasilyev
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en