Hatching eggs sucks. I'd like to hatch these eggs while I'm doing my daily running exercises. Will my movement be tracked if the app is open but the phone is locked? I ask because I attempted this with a treadmill, and I made no progress whatsoever towards my eggs.
Unfortunately distance walked only counts via GPS and not pedometer, so running on a treadmill won't lead to eggs hatching. Also the app does have to be open and the phone unlocked. There is a "battery saver" option in the in-game settings. This will dim the screen when your phone is up-side-down, such as in your pocket.
Your movement is tracked through a mixture of your phone's GPS and Pedometer. So running on a treadmill is not going to work.
As for 'locking' your screen, this will also prevent you from gaining egg progress. The app has to be active, and your phone can't be locked.
The app has to be open to track your progress.
However, if you turn on the battery saver mode in the settings you can turn your phone upside down and the screen will dim, but it will still track your progress while wasting less battery.
This app let's you lock your screen, put in your pocket or whatever and still play. Has a battery save feature as well. https://play.google.com/store/apps/details?id=com.pokegoassist.pokepal.droid