From a roleplay perspective, yes, you can be moving while casting.
From a mechanics and rules perspective, no, you are generally not considered to be in motion during the casting, because the casting a spell in combat is usually an Action, and an Action represents an instantaneous thing. For spells with longer casting times, the rules do not mention whether you can be in motion during that time; they do say (Player's Handbook p202) that your target has to be in range, but that's all.
This means that:
- a spell with a casting time of 1 action or 1 bonus action happens in an instant
- a spell with a longer casting time takes place at the instant of the last action used to cast it. For example, a 1 minute casting time is 10 rounds; the player would have to spend their action each turn for 10 turns to cast it in combat, and the effect would happen when they take the 10th action.
The different things you can do in a turn are not necessarily separate things; they are simply a way to represent how much you can get done in a short, roughly 6-second long interval.
Imagine a character with a 30ft speed, taking the following turn:
- move 10ft
- take an Action to Cast A Spell
- move 20ft
That doesn't have to mean you walk 10ft, stand still, cast, and then walk again. All it means is that you move 30ft during that 6-second time, and that your spell happens after about 10ft of movement. You could be running, and choosing to cast at the best point during that run.
(It's worth noting that you don't necessarily stop moving at the end of your turn, either; if you move 30ft on this turn, then a goblin has their turn and shoots you with a crossbow, and you move 30ft on your next turn, it could be that you just ran 60ft, but got shot halfway.)
The only relevant restriction on casting a spell is that your target has to be in range while you cast it. If, as a result of your movement, you are in range at some points and out of range at other points, you have to take the Action to cast at a point where you're in range. There are no restrictions on whether you spend movement before or after that, or on saying for the sake of roleplay that you're in motion while casting - just that from a rules perspective, the spell happened while you were in a certain place.
If the spell has a casting time of 1 action or 1 bonus action, this means you could move however you like during your turn, and take your action to cast at a point when your target is range.
If a spell has a longer casting time, whether or not the target has to be in range for the whole time is a question for your DM - the section on a spell's range on page 202 of the Player's Handbook is unclear - but in general I'd say that it has to be in range the whole time. For example, to cast hallow, you'd have to remain touching the point you're targeting for the whole time, so you couldn't move around.
If a spell is affected by movement, it would say so. For example, feather fall says you can cast the spell when you "begin falling", which means you are moving (downward) while casting. If a spell requires you to stay still while casting it would say so. It would be strange if you couldn't cast while on a ship, for example, or riding a horse - and the rules certainly don't say that this is the case.