Android - 平铺背景有时会被拉伸
我使用几个平铺的可绘制对象作为各种布局的背景。在大多数情况下,图块工作正常,但偶尔(每 4..5 次运行一次)在某些(但不是全部)背景中,单个图块图像会被拉伸以填充背景而不是重复它(导致非常“模糊”背景)。
磁贴在 xml 可绘制对象中声明如下:
`bitmap android:src="@drawable/bg_tile_dark" android:tileMode="repeat" xmlns:android="http://schemas.android.com/apk/res/android" />`
磁贴可绘制对象用作背景图像,如下所示:
` 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>
此问题发生在多个版本的 Android 和不同设备上,因此必须有一个如何使用磁贴的技巧。是否有人有使用图块背景的经验或知道强制图块始终重复的解决方法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论