Android Horizontal Screen vertical display problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.