views:

29

answers:

1

I have a background image about 100 x 100 that I want to center in an Android app. Is there a way to do this?

I'm thinking it would greatly help with orientation changes for simple apps.

+1  A: 

You can use BitmapDrawable for the case. Create centered.xml in res/drawable folder:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/your_image"
    android:gravity="center"/>

Then you can use centered drawable as background.

Konstantin Burov
This works perfectly. Thank you :)
TehGoose