First of all, how would I know they were gay by how they are dressed, especially since as you said, straight guys with female partners might dress similar? Seems pretty judgy to base someone's sexuality on what they wear.
I'd estimate maybe a quarter of the guys I see wear leggings or some sort of male yoga pants just because they don't believe quads are a thing and are too embarrassed to wear regular shorts so their chicken legs show. In fact, one regular in particular not only always wears those type of tight long pants, but stringer shirts as well, which I personally find more inappropriate since I'm sure most people there aren't into his nipples. I assume he's straight if only because he works out and sometimes gets touchy-feely with a woman whom I assume is his girlfriend and also wears attention-seeking attire such sports crop tops and padded booty shorts. They both seem to have an agenda of wanting to be seen.
As far as men in shorter than normal shorts, there's been a few and I used to wear some pretty high cut ones myself during leg days so I could better see the muscles while working out and I assume some of them might have done it for the same reasons.
So while overall, I may notice the way others are dressed, it is only as a casual observance or to make fun of their narcissism privately in my mind. I am there to work out and get in and get out, so most of my concentration is on that task at hand. As a result, I don't care what anyone wears, nor do I assume anything further about them beyond their inflated ego. I don't even care about what women wear either or are looking at them, as again, I am very task-focused when it comes to working-out.