문제

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