Thursday, February 27, 2014

Android how to call layout-land and layout


Will be to understand, first posted the code
public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
requestWindowFeature (Window.FEATURE_NO_TITLE);
/ / Set to full-screen mode
getWindow (). setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView (R.layout.main);
}
I'm new in the res of the layout, layout-land, layout-port folder, and were built a main.xml,
android: id = "@ + id / button"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: text = "layout-land" /> main.xml in the text of each show for their folder name.

Recently found in horizontal screen under (note the phone horizontally) Click Apply, it will call the layout layout-land under, this is normal, but when the phone upright, it still uses the layout layout-land under it That TextView display "layout-land".
Then I quit the application, in the vertical screen (note the vertical screen) click on the application, it will call the layout under the layout-port, this is normal, but when the phone horizontally, it still uses the layout under the layout-port , that TextView display "layout-port".

The above application is already added android: configChanges = "keyboardHidden | orientation", which is to support horizontal and vertical screen switch.

My question is, after entering the application, under TextView how horizontal screen display layout-land, switch to vertical screen display layout-port? Ie use layout-land when the horizontal screen layout, layout-port layout when using the vertical screen, rather than only when running the application in landscape or portrait valid?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
It seems built the automatic conversion, horizontal screen with horizontal, vertical screen with a vertical of
Reply:
android: configChanges = "keyboardHidden | orientation" to remove the try.
Reply:
reference to the second floor peijiangping1989 reply:
android: configChanges = "keyboardHidden | orientation" to remove the try.

Do not need to be removed, can be used directly ah
Reply:
Recently found out that my above findings are wrong.
It should be understood:
In AndroidManifest.xml not add android: configChanges = "keyboardHidden | orientation" or
android: screenOrientation = "portrait", and do not add setRequestedOrientation (mOrient) xxx.java this code in the file, then run the program, the next screen will be called horizontal layout-land in the layout, vertical screen layout-port calls in layout, the layout of the default layout calls.
After the addition of any sentence above words, when you run the program, as established in the phone is horizontal, then finished running, have been using the layout-land in the layout. If the phone is in the upright, then finished running, have been using the layout-port in the layout.
Reply:
The reply was deleted at the moderator 2011-12-31 10:50:43

Reply:
JAVA code looks like in order to fill in the relevant function on the two words it was so long ago I treated
Reply:
Is not yo, reply # 4hyz4287010

No comments:

Post a Comment