I am trying to use the image as a background in my android application. If the image does not fit the screen, I want the image to be centered horizontally and vertically vertically. The remaining area of ββthe screen should be filled with repeating edges.
My xml layout looks like this:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_image" > <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" > ... </ScrollView> </LinearLayout>
I tried marking the left and right columns as well as the top row of pixels as extensible using draw9patch. This is similar to working with smaller devices, but not on the Galaxy Tab 10.1 and Motorola Xoom. The edge repeats vertically, but not horizontally.
I also tried creating xml-drawable with tileMode = "clamp"
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:filter="true" android:gravity="center" android:tileMode="clamp" android:src="@drawable/background" />
but this does not allow me to center the image horizontally. How can I combine the clip and center_horizontal?
source share