Australian actress Margot Robbie. Photo by Richard Shotwell/Invision/AP

Margot Robbie had an awkward encounter with former US President Barack Obama at the gym when her husband Tom Ackerley almost flashed the politician.

The 'I, Tonya' actress and her spouse Tom Ackerley - who she wed in December 2016 - went on honeymoon to Tahiti and unexpectedly bumped into some familiar faces when they went to a local gym, including the former President of the United States.

But Tom was wearing some inappropriate gym wear which left him vulnerable to spillage from his shorts in front of the ex White House incumbent.

Margot recalled: "Tom was wearing his really old, really short shorts with nothing underneath. I was like, 'Woah, you can't wear those,' and he was like, 'Oh please, who are we going to see?' And I was like, 'Yeah, you're right.' So we were walking into this very small gym and there's Ellen [DeGeneres] running on the treadmill and she was like, 'Hi, I'm Ellen'. And I was like, 'Hi, I'm Margot and this is Tom'. And then she said, 'Have you met Barack?' And I was like, 'Come again?' Yes, it was Barack Obama. And we had to do this whole stretching yoga class with Tom in his little shorts and Obama stepping over his legs to put weights down and stuff and the instructor keeps going, 'Lunge, Tom, lunge.' Tom was trying to cross his legs while lunging. It was hilarious!"

Despite the embarrassing situation, the 27-year-old Australian actress got a chance to talk with 56-year-old Obama - whose wife is Michelle Obama - and was delighted to discover the former US leader was a fan of her work.

She revealed: "Yeah, he knew who I was. And he was like, 'You're a very talented actress.' And I was like, 'Oh my God, Obama knows who I am.' And he was like, 'We were just talking about you the other night.' It was crazy."