我想使用平鋪背景爲現有佈局提供紋理。所以我創建了這樣的可繪製:如何在不影響尺寸的情況下在視圖上設置背景?
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/green-linen"
android:tileMode="repeat" >
</bitmap>
其中「green-linen.jpg」是我想要使用的800x800紋理。然後,我希望在佈局上使用它,我將背景設置爲指向此。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" android:background="@drawable/background">
現在的問題是佈局認爲它需要800x800,以適應螺絲釘設計的模式。有沒有辦法設置背景,但不影響現有的佈局? B計劃可能會寫一個自定義的繪畫例程,但它可能比僅僅設計頁面樣式或設置drawable更有效,效率更低。
如果平鋪背景大於容器,則使用平鋪背景的目標是什麼? – Dalmas
容器可能更大,可能更小。取決於應用程序正在運行的設備。 – locka