A very important feature of modern mobile devices is the direction in which the screen can be rotated. Of course, Android is no exception. Android supports two screen orientations: Portrait (vertical screen) and landscape (horizontal screen). By default, when you change the screen orientation of a handheld device, the current anctivity automatically redraw its contents. This is because the OnCreate () method is triggered when the screen direction is changed.
Description: When changing the device's screen orientation, in fact, your current activity will be destroyed and recreated.
Then, when the views are redrawn, they may be drawn in the previous screen direction (depending on the layout layout selected).
<tablelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_height= "Fill_parent" Android:layout_width= "Fill_parent" > <TableRow> <textview Android : text= "User Name:" android:width = "120dp"/> <edittext android:id
= "@+id/txtusername" android:width= "200DP"/> </TableRow> <TableRow> <textview android:text= "Password:"/> <edittext android:id = "@+id/txtpassword" android:password= "true"/> </TableRow> <tabler
ow> <textview/> <checkbox android:id= "@+id/chkrememberpassword" Android:layout_width= "Fill_parent" android:layout_height= "wrap_content" android:text= "R"
Emember Password " /> </TableRow> <TableRow> <button android:id= "@+id/b Uttonsignin "android:text=" Log in "/> </TableRow> </TableLayout>
Vertical Screen mode:
Horizontal Screen mode:
Note that in Lanscape horizontal screen mode, there are some blank controls on the right side of the screen that you can use. In addition, when the screen orientation is set to landscape, any view below the screen is hidden.
In general, there are two ways to handle those changes when the screen direction changes.
Add anchor points-the easiest way is to put your views "anchored" on the screen for four weeks. When the screen method changes, this view can be naturally "anchored" in the screen for four weeks.
Resize and position-anchoring and centralizing are simple ways to handle changes in the screen direction, and the more advanced approach is to resize and position each view based on the current screen orientation.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/