how to get android gradient center light effect?

前端 未结 5 1932
遥遥无期
遥遥无期 2021-02-01 14:09

i want something like following image

\"enter

i tried it using drawable shape

5条回答
  •  时光说笑
    2021-02-01 14:39

    If the aspect ratio of the oval you need is fixed, then you can use the gradient drawable as a background and use scaleX or scaleY to stretch it into an oval.

    drawable myradial.xml:

       
       
           
           
       
    

    view using it as a background

       
    

    If the aspect ratio is not fixed, it still might be possible to set scaleX in code at runtime.

    This will not work for everyone in all situations. It can make for tricky layouts. One nice things is it is a single render pass, compared to the 3 passes of the very elegant solution posted with 2 linear gradients over a solid. It also can be used to stretch out any gradient, for example to create a linear gradient at a 22.5 degree angle.

提交回复
热议问题