<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/wallpaper" />
</RelativeLayout>
The size of @drawable/peetscoffee_wallpaper
is 640x480, but it is not centered horizontally.
How can I fix this?
Try android:gravity="center"
, or android:layout_gravity="center"
, instead of centerHorizontal="true"
.
However, i doubt this will behave sensibly with an image that size set to wrap_content
- you may want to define some image scaling method with android:scaleType
(eg fitCenter
) and set it to fill_parent
rather than wrap_content
. 640x480
is bigger than the 320x480
the current real-world Android devices support. Or just scale down that image you're using so the device doesn't have to do the work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With