ーI was listening to my teacher, but sort of absent-mindedly.
「先生の話を聞いていたが、ちょっと上の空だった」
absent-mindedly を使って「うわの空」を表現できます。
ーI talked to her, but it was like she wasn't with me at all.
「彼女と話したけど、全くうわの空だった」
to not be with someone を使って「うわの空」を表現することもできます。
ご参考まで!
よく使われるのは、have one's mind elsewhere です。
直訳すると「心が別の場所にある」で、「うわの空」のニュアンスにとても近いです。
She had her mind elsewhere during the meeting.
彼女は会議中、うわの空だった。
また、「注意を払っていない」という意味で not paying attention もよく使います。
He wasn’t really paying attention in class.
彼は授業中、うわの空だった(あまり注意を払っていなかった)。
absent-minded は「ぼんやりしている」「注意散漫な」という意味です。ただしこれは性格的・一時的どちらにも使えます。
She seemed absent-minded today.
彼女は今日うわの空のようだった。