// Obtain the direction when switching the screen
If (this. getresources (). getconfiguration (). Orientation = configuration. orientation_landscape ){
Settitle ("Landscape ");
}
If (this. getresources (). getconfiguration (). Orientation = configuration. orientation_portrait ){
Settitle ("portrait ");
}
// Obtain screen size 1
Windowmanager manager = getwindowmanager ();
Int width = manager. getdefadefadisplay (). getwidth ();
Int Height = manager. getdefadefadisplay (). getheight ();
// Obtain the screen size 2
Displaymetrics dmetrics = new displaymetrics ();
Getwindowmanager (). getdefaultdisplay (). getmetrics (dmetrics );
Int screenwidth = dmetrics. widthpixels;
Int screenheight = dmetrics. heightpixels;
Use the getlayoutparams () method and setlayoutparams () method.
1. First, use the getlayoutparams () method to obtain the control's layoutparams.
Eg: layoutparamslaparams = (layoutparams) imageview. getlayoutparams ();
2. Set the layoutparams parameter of the control.
Eg: Laparams. Height = xxx;
Laparams. width = YYY;
3. Set the modified layoutparams to the layoutparams of the control.
Eg: imageview. setlayoutparams (laparams );