I have a RelativeLayout where I need to have a black background and a small image exactly in the middle of it. I used this code:
<RelativeLayout
android:id="@+id/bottomBox"
android:layout_weight="4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bottom_box_back"
android:layout_marginTop="4dp"
/>
where the @drawable/bottom_box_back is:
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/logo_icon"
android:tileMode="disabled"
android:gravity="center"
android:filter="true"
/>
In this way I have the image centered. But the background is still gray as the main window. I need a black back to the image spread all over the RelativeLayout space. Any suggestions?
I would make the background of your RelativeLayout black and then put the Image into an ImageView and center that in the middle of the RelativeLayout, so:
Hope this helps you