Develop mobile appsProgramIn addition to the underlying understanding of the API, the most important thing is the screen resolution concept of ligala, because various mobile phone manufacturers use different screen sizes, the presentation and layout of the UI interfaces are also quite different.
Android can be set to adjust the scaling ratio with the window size. However, even so, mobile phone programmers must still be aware of the boundary of the mobile phone screen to avoid layout deformation caused by scaling, the following is a small example. You only need a few words to get the resolution of the mobile phone. The most important thing is the displaymetrics application.
Metrics ['metriks] measurement, measurement
Heightpixels: displays absolute pixels of height.
Widthpixels: absolute pixel of display width
Package Org. hualang. Other; Import Android. App. activity; Import Android. content. res. Resources; Import Android. Graphics. drawable. drawable; Import Android. OS. Bundle;Import Android. util. displaymetrics; Import Android. widget. textview; Public Class Other Extends Activity { /** Called when the activity is first created .*/ Private Textview text1, text2; @ override Public Void Oncreate (bundle savedinstancestate ){ Super . Oncreate (savedinstancestate); setcontentview (R. layout. Main );// Android. util. displaymetrics must be referenced Displaymetrics dm = New Displaymetrics (); getwindowmanager (). getdefadisplay display (). getmetrics (DM); string stropt =" Cell phone screen resolution: "+ DM. widthpixels +" X "+ DM. heightpixels; text1 = (textview) findviewbyid (R. Id. text1); text1.settext (stropt );}}