【问题标题】:How can I make this type of gradient in drawables?如何在可绘制对象中制作这种类型的渐变?
【发布时间】:2018-01-19 13:54:20
【问题描述】:

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

【问题讨论】:

  • 只旋转你的drawable/view
  • @VladMatvienko 当我旋转视图时,视图周围会有空格
  • 在问题中添加代码

标签: android gradient


【解决方案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>

【讨论】:

  • 我没有使用'angle','android:cenerX'和'android:centerY'没有用。
  • 你注意到我问题图片中的角度了吗?
【解决方案2】:

设置开始和结束颜色相同和不同的中心颜色并将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>

【讨论】:

    【解决方案3】:

    我找到了办法,

    <?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"。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-06
      • 2018-06-19
      • 1970-01-01
      • 1970-01-01
      • 2020-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多