【发布时间】:2017-06-13 21:44:57
【问题描述】:
【问题讨论】:
-
或者你可以查看this库。
-
使用
ValueAnimator/ObjectAnimator绘制GradientDrawable(或LinearGradient,如果您需要更多功能)
标签: android android-studio animation gradient
【问题讨论】:
ValueAnimator/ObjectAnimator绘制GradientDrawable(或LinearGradient,如果您需要更多功能)
标签: android android-studio animation gradient
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#3B5998"
android:endColor="#00000000"
android:angle="45"/>
</shape>
然后在你的主 xml 中
<include
android:id="@+id/include1"
layout="@layout/actionbar" />
【讨论】:
例如在 XML 中
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#2E383E"
android:endColor="#798B97"
android:angle="45"/>
</shape>
创建一个 TransitionDrawable 以在您用于背景的两个可绘制对象之间进行切换。
<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<!-- use whatever drawables you want, gradients, shapes etc-->
<item android:drawable="@drawable/start" />
<item android:drawable="@drawable/end" />
</transition>
Transition Drawables in Android
TransitionDrawable trans = (TransitionDrawable) myLayout.getBackground();
trans.startTransition(2000);
【讨论】: