views:

1030

answers:

2

I've tried all scaletypes, but all of them result in the image to be at the left corner of the imageview.

 <ImageView
    android:id="@+id/image"
    android:scaleType="centerInside"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:layout_marginRight="6dip"
    android:background="#0000" 
    android:src="@drawable/icon1" />
+1  A: 

Your ImageView has the attribute wrap_content. I would think that the Image is centered inside the imageview but the imageview itself is not centered in the parentview. If you have only the imageview on the screen try fill_parent instead of wrap_content. If you have more then one view in the layout you have to center the imageview.

Janusz
I do have more than one view in the layout. What exactly do you mean by "center the imageview"?
Yang
The ImageView itself should be inside a layout component. This surrounding layout component can arrange the child elements... If you could post your whole layout file I could try to give you some more precise hints.
Janusz
A: 

You can center the ImageView itself by using:

android:layout_centerVertical="true" or android:layout_centerHorizontal="true" For vertical or horizontal. Or to center inside the parent:

android:layou_centerInParent="true"

But it sounds like you are trying to center the actual source image inside the imageview itself, which I am not sure on.

Matt Swanson