I'd like to flash/blink the stroke of a button a few times based on a timer. For example, every 30 seconds flash the stroke 3 times from white to black or some such thing. Can this be done? Thanks

有帮助吗?

解决方案

you can create custom button layouts like such and put them in the drawable folder

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item>        
    <shape>
        <gradient
            android:endColor="@color/white"
            android:startColor="@color/whitesmoke"
            android:angle="270" />
        <stroke
            android:width="2dp"
            android:color="@color/grey3" />
        <corners
            android:radius="10dp" />
    </shape>
</item>

where the color grey3 is the border and you can start a timer and add a TimerTask class to your class and then make it run the task every 30 seconds and just change the buttons background from one .xml to another with a different border color.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top