如何制作渐变色并在ImageView(android)上进行设置



gradient.xml:

<gradient
android:angle="135"
android:endColor="#aaFFB5B9"
android:startColor="#aaFFDEB5"
/>
<corners android:radius="0dp" />
<size
android:width="120dp"
android:height="120dp"/>

gradient2.xml:

<gradient
android:angle="135"
android:startColor="#aaECB4FF"
android:endColor="#aaB4CCFF"
/>
<corners android:radius="0dp" />
<size
android:width="120dp"
android:height="120dp"/>

图像视图:android:前景="@"可拉伸/梯度";

图像视图2:android:前景="@可绘制/梯度2";

在您的drawable/gradient.xml中:

<?xml version="1.0" encoding="utf-8"?>
<!--You have to specify the shape of the gradient-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:angle="135"
android:endColor="#aaFFB5B9"
android:startColor="#aaFFDEB5"
/>
<corners android:radius="0dp" />
<size
android:width="120dp"
android:height="120dp"/>
</shape>

在您的图像视图中:

<ImageView
...
android:src="@drawable/gradient"
/>

对ImageView2 执行相同操作

最新更新