Android background color scanning gradient can be defined by defining an xml file in res/drawable (the name of the xml file can be defined according to the individual):
1. sweep_gradient.xml code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#03A9F4"
android:centerColor="#FF5722"
android:endColor="#FF9800"
android:type="sweep"
android:centerX="0.5"
android:centerY="0.5" />
</shape>
1. android:startColor start color
2. android:centerColor middle color
3. android:endColor end color
4. android:type gradient type, scan sweep
5. centerX, centerY: x and y coordinates of the center radial point, the value is 0-1.0, centerX takes 0.5 to indicate horizontal centering, centerY takes 0.5 to indicate vertical centering
2. Use it in the interface you want to implement:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ColorActivity"
android:orientation="vertical"
android:background="@drawable/sweep_gradient">
</LinearLayout>