How did the movie makers make "Odie" act with an animated character.
By using a couple of very well trained dogs...
The part of Odie was played by two Dachshund mixes named "Tyler" and "Chloe"
The dance-off in particular was a combination of blue-screen, the dog reacting to trainer commands and many, many takes.
Garfield shoves Odie off the chair various times, and they engage in a dance-off competition that features Odie hopping around on his back legs. Though they're having fun together, Garfield propels Odie across the porch when his other cat friends show up.
For this sequence, trainers first positioned "Tyler" in a stay position on a blue screen floor. As "Tyler" hopped on his back legs, a second trainer called the dog to come in the opposite direction and cued him to spin in circles in one spot.
This same action was repeated for various takes from different angles, and "Tyler" was conditioned and prepped for this scene for three weeks before actual filming began.
For this and many other details on the various sequences see Humane Hollywood