如何在drawable中制作这种类型的渐变?

时间:2018-01-19 13:54:21

标签: android gradient

我使用渐变类型作为扫描,但startColor从3点钟开始,我该如何更改角度?

This is the picture.

3 个答案:

答案 0 :(得分:1)

从代码中删除角度并给予android:centerY =" 0.5"和android:centerX =" 0.5"你的问题将得到解决。

<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle">
<gradient
    android:type="sweep"
    android:centerColor="#FA364D"
    android:endColor="#212545"
    android:startColor="#212545" 
    android:centerY="0.5"
    android:centerX="0.5"/>
</shape>

enter image description here

答案 1 :(得分:0)

将开始和结束颜色设置为相同且不同的中心颜色,并将centerX和centerY设置为0.5

尝试这个

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
   <gradient
    android:type="sweep"
    android:centerY="0.5"
    android:centerX="0.5"
    android:centerColor="#303F9F"
    android:endColor="#3F51B5"
    android:startColor="#3F51B5" />
</shape>

答案 2 :(得分:0)

我找到了办法,

<?xml version="1.0" encoding="utf-8"?>
    <shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    >
    <gradient
        android:type="sweep"
        android:startColor="#212545"
        android:centerColor="#FA364D"
        android:endColor="#212545"/>
</shape>

我创建了TextView,其背景为android:rotation="135"以及android:scaleX="99"android:scaleY="99"

相关问题