一手遮天 Android - UI: shape 渐变色(线性渐变,放射性渐变,扫描式渐变)
示例如下:
/ui/ShapeDemo1.java
/**
* shape 渐变色(线性渐变,放射性渐变,扫描式渐变)
*
* 扫描式渐变的意思就是转着圈渐变
*/
package com.webabcd.androiddemo.ui;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.webabcd.androiddemo.R;
public class ShapeDemo1 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ui_shapedemo1);
}
}
/layout/activity_ui_shapedemo1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--线性渐变,参见 res/drawable/shape_sample_gradient_linear.xml-->
<TextView
android:id="@+id/textView1"
android:layout_width="200dp"
android:layout_height="100dp"
android:background="@drawable/shape_sample_gradient_linear" />
<!--放射性渐变,参见 res/drawable/shape_sample_gradient_radial.xml-->
<TextView
android:id="@+id/textView2"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="@drawable/shape_sample_gradient_radial" />
<!--扫描式渐变,参见 res/drawable/shape_sample_gradient_sweep.xml-->
<TextView
android:id="@+id/textView3"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="@drawable/shape_sample_gradient_sweep" />
</LinearLayout>