문제

There is no problem with portrait mode but when i try my app on landscape mode it doesn't look how it should.What is general aproach to solve this problem.My first idea is replacing X and Y places.If i am on the right track how should i do this ? Should i use an if statement at the beginning of the onDraw() function and write entire same code twice (one for x,y and other is for y,x) ?

도움이 되었습니까?

해결책

There should be no need for your to swap the X and Y coordinates in your drawing. By default, when apps are rotated, so are the coordinate systems.

다른 팁

It sounds like you are specifying absolute widths and heights for your drawing calls. For instance, if you saved myWidth = 480 and myHeight = 800 early on, and do all your drawing this way, then when the device is rotated, those widths and height no longer apply.

I think the solution for you here is to listen to size changed callbacks and reset your idea of width and height accordingly. If you are drawing directly in a view, you want to override View.onSizeChanged().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top