边框纹理视图 [英] Border texture for a View

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

问题描述

有什么办法来设置边框纹理的LinearLayout 或任何其它查看?我不能只是将图像设置为,因为不同的屏幕尺寸的背景。

Is there any way to set border texture for LinearLayout or any other View? I can't just set an image as the background because of different screen sizes.

下面是纹理我谈论的例子:

Here is the sample of the texture I'm talking about:

我试图用的九补丁的,但它延伸的白线,都应该被重复。

I tried to use Nine-patch, but it stretches the white lines that are supposed to be repeated.

截图从中汲取9补丁工具:

推荐答案

您可以使用形状绘制这样的:

You can use shape drawable like this:

<shape android:shape="rectangle">
    <solid android:color="#FAFAD2" />           
    <stroke android:width="1sp" android:color="#000000"
        android:dashWidth="7sp" android:dashGap="5sp" />
</shape>

和这将导致你的东西是这样的:

and this will result you something like this:

您可以根据你的要求改变颜色,宽度,边框等。

You can change color, width, border etc according to your requirements.

这篇关于边框纹理视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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