4
我想在我的android應用程序中使用圖像作爲背景。如果圖像不適合屏幕,我希望圖像水平居中並垂直放置。剩餘的屏幕區域應通過重複邊緣來填充。居中位圖並重復邊緣像素
我的佈局XML看起來是這樣的:
<?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>
我想左,右列以及像素的頂行可拉伸使用draw9patch標記。這似乎適用於較小的設備,但不適用於Galaxy Tab 10.1和Motorola Xoom。邊緣垂直重複,但不水平重複。
我也試圖創建一個XML抽拉與TILEMODE =「鉗」
<?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"
/>
但是,這並不讓我水平居中的圖像。 我怎樣才能結合夾和center_horizontal?