我想使用平铺背景为现有布局提供纹理。所以我创建了这样的可绘制:如何在不影响尺寸的情况下在视图上设置背景?
<?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