Hi, I stumbled across this forum accidentally in my search for a post I made on a Sony forum where lots of people are having the same problem with their Sony Xperia XA. I have found a solution that worked for me and might work for other people.
This is a cut and paste of my post on the Sony site. It might not work for your phone but I would have thought the principle is the same and this is such a frustrating problem and has been expensive for some too that it does need trying out, Good luck and here's what I did:
I see that lots of people are having the problem of their phone not charging and remaining on the red light. I had exactly the same problem until I ditched the USB lead and plug adaptor and used a dedicated phone charger I had lying around. I'm referring to the ones where the leads are wired into the plug and not removable. Finally I got it from red and healthily into the orange light and thereon in the USB charger should work too. Mine certainly did. I noticed that it seems v.slow getting out of red but once in orange it charges quite speedily.
I'm not a techy but it does kind of make sense. I'm guessing that the phone needs an extra energy push when it's on red and the apparent poor quality build of the battery means that it isn't as responsive with a USB + plug because they charge the phone slower and therefore there's less power in them. All it can do is keep the phone running and can't charge it.