Search code examples
androidimageimageviewscreencenter

Android: ImageView in center screen


I have a background image in full screen with a RelativeLayout. And other image (100x100) in an ImageView.

I want to put the ImageView in center screen. But my image shows top left.

What is the problem?

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fondo_inicio" >

<ImageView android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_gravity="center"
    android:gravity="center"
    android:background="@drawable/icono_inicio"/>

</RelativeLayout>

Solution

  • try this to your ImageView

    android:layout_centerInParent="true"