Wednesday, 21 August 2013

Centering an ImageView in FullScreen mode

Centering an ImageView in FullScreen mode

I am simply trying to center an ImageView in a FullScreen app. I've read
several posts on this site on people asking what seems like same question,
and I've tried everything I've read, but I can't seem to get it to center.
Here is my code for the layout. I realize there might be some overkill
here to get the centering, as a result of trying various other posts. This
code puts the image on the top left part of the screen.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:background="#000000"
android:orientation="vertical" >
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="false"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:contentDescription="@string/descImage"
android:cropToPadding="false"
android:gravity="center"
android:src="@drawable/placeholder" />
Here is my full screen code in AndroidManifest.xml.
android:screenOrientation="landscape"
android:theme="@style/Theme.FullScreen">
Theme.FullScreen is defined as
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo">
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
</style>
Thanks.

No comments:

Post a Comment