图像背景 - 如何将图像重复为背景而不是拉伸它

lio*_*ior 6 android background image repeat stretch

我有一个图像,我想用作一些布局的背景.问题是图像包含斜线纹理,所以如果我使用1像素宽度图像或9补丁图像被拉伸,纹理是Twitching,所以我可以看到斜线作为纬度线.我看到他的android模拟器在进度条中使用了类似的纹理不确定动画,是否有一个特殊/简单的定义来命令背景图像重复自己而不是拉伸?有没有办法用9补丁来做,因为最终我也需要圆角.谢谢您的帮助.

Sub*_*ian 29

当Xandy回答时,你可能想看看瓷砖模式.以下是一些供您参考的代码供我使用.

repeat.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/img"
    android:tileMode="repeat" />
Run Code Online (Sandbox Code Playgroud)

main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/repeat">
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)