Positioning an image inside an ImageView with gravity: top?

You can use ImageView.ScaleType. MATRIX and set image matrix using ImageView.setImageMatrix() Matrix can be obtained using Matrix.setRectToRect() method.

You can use ImageView.ScaleType. MATRIX and set image matrix using ImageView.setImageMatrix(). Matrix can be obtained using Matrix.setRectToRect() method.

I think this can be solved if you gave suitable value for android:layout_marginTop,android:layout_marginLeft,.......android:padding...android:adjustViewBounds... . I just naming some to just show you have to select suitable properties to your actual image.

Depending on what else is in the layout, a solution could be to use another layout (i.e. A FrameLayout which is rather light) in place of the ImageView, and have the ImageView in place of the actual image, with its android:layout_gravity="top".

I use Linear layout. I try all of your comment, but I can only change the position of imageview, not image inside imageview – ZuzooVn Apr 29 at 3:42 @ZuzooVn: the only way to move an image inside ImageView is using android:scaleType, and the only setting that will let you do what you want is android:scaleType="matrix", with a matrix that will translate to the horizontal center the image. As this is non trivial, I suggest rethinking your layout.(see my suggestion) – bigstones Apr 29 at 10:33.

With android:layout_alignParentTop="true" and android:layout_centerHorizontal="true" you can achieve the desired effect.

I must use linear layout. See my xml in my post – ZuzooVn Apr 28 at 13:03 Is there a specific reason why you encapsulate every view in a seperate layout? I don't see the necessity of it... – Mokus Apr 28 at 13:10 I use it in my URL1 make me easier to display many thing in my app – ZuzooVn Apr 28 at 13:13 Did you try android:layout_gravity="top|center"?

– Mokus Apr 28 at 13:22 Yes, but nothing change – ZuzooVn Apr 287 at 3:40.

Have you tried using the attribute android:gravity = "top" I see that for your ImageView you are using android:layout_gravity maybe you could try using the other one. As far as I know, the "android:layout_gravity" attribute is used for setting the gravity of the element within its parent, while the "android:gravity" attribute is for setting the gravity of the element's contents. (Someone correct me if I'm wrong!

=P hehe! ).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions