I am working on a android project where the user can scan a RFID tag. The tag expires after a certain amount of seconds to clear up the system before another tag comes in, basically to avoid processing the same tag twice by mistake. To visualise this timeout I want the background of the button where the tags ID is displayed to be animated. Basically I want the entire button to be filled with color when the tag has just been scanned and slowly scale down to the middle as time processes.
What I have found so far: I found this answer where they talk about the properties api. I could see this working with a gradient but unfortunately the documentation on gradients is sparce and it looks like it wouldnt be that easy to do that with.
I also thought that maybe you could achieve this by somehow layering another view of the same size below the button and scaling that. But honestly I think this would be quite difficult to do consistently, especially with resizing the view while the timer processes and configuration changes. Then again, I am not really that experienced with android and use linear and grid layouts for almost everything since they are the easiest to understand.
All I would really need is some way to essentially "scale" the background by a value (the ratio between total time and time left) towards the middle like I have demonstrated here. Or a way to essentially have a hard color gradient where the white portions of the gradient move towards the middle as the time processes.
Last solution I thought could maybe work is to have a animated vector drawable and manipulate the objectanimator associated with it to force it to play at the right speed. However, this solution is probably pretty messy, thought I haven't tried it (yet)
Does anyone have a clean solution to this problem?
Note: i am using java for this project. I did not include code snippets because I didn't think they were needed. If you need some snippets please simply ask and I will provide. My minSdkVersion is 25 since the target device for the job has android 7.1 and cannot be updated to a newer version.