android - drawable 中的 tileMode 重复将不起作用

标签 android

<分区>

我有这个可绘制资源:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/bg_stripe"
    android:tileMode="repeat"
    android:antialias="true"
    android:dither="false"
    android:filter="false"
    android:gravity="left"
/>

这里用作背景:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_world_locked" >

有时一切正常,有时不正常(可绘制资源以其真正的小尺寸出现并且不重复)。为什么?这是安卓的bug?我在我的 HTC Desire Android 2.3 上运行它。

最佳答案

不幸的是 - 这是 Android 错误。检查这个答案

Tiled drawable sometimes stretches

简而言之:您应该在 Java 代码而不是 XML 中设置重复。

关于android - drawable 中的 tileMode 重复将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15924359/

相关文章:

java - 为什么我在没有使用 android.os.CountDownTimer 调用 Looper.prepare() 的线程中得到一个 "Can' t 创建处理程序?

android - 即使现在已弃用,如何使用 Place Picker?

android - SQLite 和 Android : unable to open database file - error 14

android - 在我的 android webview 中,显示了 URL 但我想删除它并且它总是在浏览器中打开我不想要那个

android - 线性布局上有类似 "bringToFront()"的方法吗?

android - 想在 android 中为 21 英寸屏幕提供布局

使用 proguard 的 Android 混淆应用程序会不断混淆库 jar - 是吗?

java - 在这种情况下,当仅调整图像(png)大小时,BitmapFactory 真的有必要吗?

android - 找不到兼容的并排 NDK 版本 React Native

android - 自定义 Android 内核 - 无法加载内核模块