1. Use different layout files
Res file
Select Layout Ctrl + C
Select Res Ctrl +v
Create layout for Layout-land horizontal screen display
Similarly create layout for the Layout-port vertical screen display
Picture Horizontal screen Vertical screen
Check DRAWABLE-XHDPI Ctrl + C
Select res Ctrl + V
Create drawable-land-xhdpi
The same is true for other resolutions.
string
Values-land
Values-port
In addition: (Layout folder can also use keywords such as Hdip,mdip name, such as Layout-hdip,layout-mdip)
Display different layout layouts depending on resolution
2 Force Horizontal screen display (not adjusted by phone sensor)
Add in <activity:
android:screenorientation= "Landscape"//Horizontal screen//portrait vertical screen
Note:
Activity is recreated during vertical screen switching
The OnCreate method will re-execute
If there is no ID of the component such as edit box and so on the horizontal screen fill in the edit box data, write to half after if the vertical screen display,
Data is lost
Google Solutions:
If you have an ID
The corresponding value in the ID component is stored temporarily after the first activity is created and the OnCreate () method is executed.
When you create an activity again after rotation
But after the OnCreate () method is executed!!!!! After execution!!!!
Find the corresponding value by ID fill it up
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Horizontal Screen vertical display problem