Android LinearGradient XML

后端 未结 4 1955
时光说笑
时光说笑 2021-02-03 20:27

I\'m facing a small problem with the LinearGradient definition in XML. What I want is to use the constructor that accepts the array of colors and the array of positions.

<
4条回答
  •  面向向阳花
    2021-02-03 20:45

    You have an option if you are creating a Gradient on java.

    LinearGradient lg = new LinearGradient(0, 0, width, height,
                new int[]{Color.GREEN, Color.GREEN, Color.WHITE, Color.WHITE},
                new float[]{0,0.5f,.55f,1}, Shader.TileMode.REPEAT);
    

    Set this to your view's background.

提交回复
热议问题