问题描述
我试图加载在Android的位图,我想瓦。我目前使用以下在我看来,以显示位图:
I'm trying to load a bitmap in Android which I want to tile. I'm currently using the following in my view to display a bitmap:
canvas.drawBitmap(bitmap, srcRect, destRect, null)
我基本上是想用这个图作为我的应用程序的背景图像,并想重复位图在X和Y方向。
I essentially want to use this bitmap as a background image in my app and would like to repeat the bitmap in both the X and Y directions.
我见过的TileMode.REPEAT常数BitmapShader类,但我不能确定这是否是做重复他实际位图或做应用滤镜的位图。
I've seen the TileMode.REPEAT constant for the BitmapShader class but am unsure if this is to do with repeating he actual bitmap or to do with applying a filter to the bitmap.
推荐答案
您将在XML而不是Java的code做到这一点。我还没有尝试这个自己,但我没有找到这个例子。
You would do this in the xml instead of the java code. I haven't attempted this myself but I did find this example.
<xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainLayout"
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"
>
然后在XML名为backrepeat.xml
then in an xml called backrepeat.xml
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/back"
android:tileMode="repeat" />
reference
这篇关于Android的瓷砖位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!