问题描述
我正在开发一个android应用程序。在此应用程序中,我要移动颜色,如下图所示。
1)我尝试过旋转背景可绘制对象:This
2)我尝试过动画列表,但这不是解决方案。
布局
$totalah = Sah::find()
->select(['mhs','SUM(IF(status_kehadiran = 1,status_kehadiran,0)) AS K3211335'])
->where([
'kode_mk'=> 'K3211335'
])
->groupBy('mhs')
->all();
@ drawable / border
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/border"
android:contentDescription="@string/qr"
android:cropToPadding="true"
android:padding="10dp"
android:scaleType="centerCrop"
/>
注意: 我不是在寻找旋转视图。因为imageview中有内容。因此,请勿建议使用ViewPropertyAnimator类
解决方法
一种方法是使用计时器进行渐变。 这是两个示例,一个改变颜色,另一个改变角度,从而产生旋转效果。
您可以根据需要对其进行调整。
但是要警惕性能,具体取决于您希望它改变多快。
旋转效果
Auto-merging file1.txt
CONFLICT (content): Merge conflict in file1.txt
error: could not revert 96882d9... second commit t2
hint: after resolving the conflicts,mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
变色效果
//Call this once to change gradient angle
private fun startAngleChangeJob() {
var shape = imageView.background
var borderGrad = shape as GradientDrawable
var timer = fixedRateTimer("colorTimer",false,0L,100) {
var ori = borderGrad.orientation.ordinal
var newOri = (ori + 1) % 7
[email protected] {
borderGrad.orientation = GradientDrawable.Orientation.values()[newOri]
}
}
}
变色效果
//Call this once in onCreate to change gradient colors
private fun startColorChangeJob() {
var timer = fixedRateTimer("colorTimer",100) {
var shape = imageView.background
var borderGrad = shape as GradientDrawable
var colors = borderGrad.colors
var colorsNew = IntArray(colors!!.size)
for (i in colors.indices) {
var newInd = (i + 1) % colors.size
colorsNew[newInd] = colors[i]
}
[email protected] {
borderGrad.colors = colorsNew
}
}
}