Snippet content is not displayed on the handset
I am trying to get my fragment to appear on my mobile, but for some reason it won't do it. However, when loading the same thing onto a tablet, it looks like normal. Anyone what's wrong with my code and how to fix this issue? All related help would be appreciated.
Class references
Links to layouts
+3
source to share
3 answers
Please make sure that you have not designed the layout in landscape mode for Android phones, then the question arises how to control in tablets.
Place this boolean resource in res / values as bools.xml or whatever (filenames don't matter here):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="portrait_only">true</bool>
</resources>
Place this in res / values-sw600dp and res / values-xlarge:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="portrait_only">false</bool>
</resources>
Then on the java side check a condition like
if(getResources().getBoolean(R.bool.portrait_only)){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
-1
source to share