gpt4 book ai didi

android - 我如何使用形状而不是图像创建带条纹的背景

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:04:16 26 4
gpt4 key购买 nike

我想知道如何在不实际添加背景图像的情况下创建具有不同颜色线条的背景。我想用 java 中的任何形状或一些代码来解决它。

非常感谢! enter image description here

最佳答案

这是我的 9 补丁(我称之为 /res/drawable/stripes_vert_4.9.png):

enter image description here <= 看!就在这里!大小为 14*5 像素,包括边框。重量:205 字节

这是设置为背景时的结果:

enter image description here

现在是半透明渐变(我称之为 /res/drawable/bg_stripes_vert_gradient):

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:startColor="#0000"
android:endColor="#8000"
android:gradientRadius="180"
android:type="linear"
android:angle="-90"
/>
</shape>

使用 start|center|endColor 以获得最佳平衡。
现在,布局:

<?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/stripes_vert_4"
>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_stripes_vert_gradient"
/>
</RelativeLayout>

最终结果:

enter image description here

关于android - 我如何使用形状而不是图像创建带条纹的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23933618/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com