tiled backgrounds occasionally get stretched

I use several tiled drawables that are used as backgrounds for various layouts. For the most part the tiles work correctly but occasionally (once on every 4..5 runs) in some (but not all) of the backgrounds a single tile image gets stretched to fill in the background rather than repeat it (resulting in a very "fuzzy" background).

Tiles are declared in an xml drawable like this:

`bitmap android:src="@drawable/bg_tile_dark" android:tileMode="repeat"
  xmlns:android="http://schemas.android.com/apk/res/android" />`

The tile drawable is used as a background image like this:

` RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/my_background_tile" >
`
....
/RelativeLayout>

This issue happens across multiple versions of Android and on different devices so there must be a trick to how to use tiles. Does anyone have experience using tile backgrounds or knows a workaround to force tiles to always repeat?

链接地址: http://www.djcxy.com/p/5320.html

上一篇: 使用自定义适配器/ layoutinflator时,垂直对齐textview列

下一篇: 平铺的背景偶尔会被拉伸