songz / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
Other
162 stars 270 forks source link

Android views are half the size (works on iOS) #66

Closed rishi-livewiretax closed 10 years ago

rishi-livewiretax commented 10 years ago

I'm having the same issue as #20 .

image

When I change the code here, it works perfectly. Basically, my views were half the size and positioning they should have been, and multiplying by 2 fixed the problem.

What I did was (multiply by 2):

mView.setY( (float) mProperty.getInt(1) * 2 );
mView.setX( (float) mProperty.getInt(2) * 2 );

and

params.height = mProperty.getInt(4) * 2;
params.width = mProperty.getInt(3) * 2;

Doing the above makes it work perfectly:

image

I could submit a pull request, however, I have no clue why I need to multiply by two. When I check logcat, it's reporting the correct positions and correct width/height, so I don't know why the views are half-positioned and half-sized.

songz commented 10 years ago

Hello. I haven't seen this before, but I have a haunch. On the javascript side, width/height and top/left are calculated and then passed to Android. The most logical reason why this is happening is that the javascript width is not the same as the android width.

If this is the case, one idea for a fix is to always pass in the javascript full width and full height of the screen into the android code. In android, we get the full width and height in Java. Then, we can get js/java ratio. Whenever we set the position/dimensions of the views, we do: mProperty.getInt * (js width/java width)

What do you think?

rishi-livewiretax commented 10 years ago

Yeah, you're right. The disparity is in the viewport size vs the entire browser window's size.

For example window.outerWidth and window.outerHeight both match the size that android is reporting. However, window.innerWidth and window.innerHeight are the correct measurement (half the size on my phone).

So, there's actually no need to get the size in android. We can just give a ratio of window.outerWidth / window.innerWidth #67 fixes this.

rishi-livewiretax commented 10 years ago

Closed, as issue was resolved by #67

sureshkoduri commented 9 years ago

I did what you said above. But not working.