Reputation: 3831
I'm new to cordova/phonegap and just recently created my first app. It's not finished yet, but there's one issue I really need help with (I've no idea on where to start).
When testing my app on simulator and on device, it gets some black margins on top and bottom (landscape only app). When I touch on black borders I can move my content and try to adjust it to screen (it's bigger than screen but keeps proportions). So I have to keep moving it up and down so I can see all my content (sometimes left and right).
So, how can I make it to fit my screen. As I have no header or footer I just need my body div to adjust to screen and stay fixed there.
Thanks.
Upvotes: 0
Views: 234
Reputation: 3831
I found one only solution that made the deal. I had to go into my css and add this into my body tag:
position: absolute;
top: -16%;
So my body div went up in screen, positioning my content correctly
Upvotes: 0
Reputation: 45
The size can be manually defined in the AndroidManifest.xml file
In case the configuration is changed to landscape mode the activity is killed and then restarted. To improve speed and retain data you can either-
create arbitrary java object which caches important state configuration using the onRetainNonConfigurationInstance() which will be called between the onStop() and onDestroy(). It returns and object which can be retrieved by getLastNonConfigurationInstance() in the onCreate() method
A similar process can be done by using fragments. The hosting activity is killed and recreated so it kills fragments also. To Prevent that-
onCreate(Bundle b){
//code
setRetainInstance(true);
}
Now it retains the fragment , detaches it but won't destroy it so it won't be recreated.
Manual Reconfiguration can also be done to avoid shut down and restart. Declare the configuration changes your activity handles in "AndroidManifest.xml". when the configuration changes call is made to onConfigurationChanged()
Upvotes: 1