我希望在我的Android应用中添加嘈杂的背景。纹理是完美的,我可以创建一个九绘图像,但是当我在应用程序中实际使用它时,它会在整个背景中伸展线。有什么想法是,实施这种类型的纹理将是什么更好的方法?

我还希望为动作栏使用类似的东西。

NoisyGrey

有帮助吗?

解决方案

9点会伸展,您必须指定图像中应伸展的区域。您为什么不尝试重复可绘制的能力。像这样:

<xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/YourLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat"
>

然后在一个名为backrepeat.xml的XML中

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/back" 
    android:tileMode="repeat" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top