Android的瓷​​砖位图 [英] Android Tile Bitmap

查看:79
本文介绍了Android的瓷​​砖位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载在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" />

<一个href="http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background-cont.html">reference

这篇关于Android的瓷​​砖位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆