1. Referencing the system's own style font size
For controls that can display text (such as TextView EditText RadioButton Button CheckBox chronometer, and so on), you sometimes need to control the size of the font. The Android platform defines three font sizes.
Use the following method:
Or
Font Color
ProgressBar
Separator
Transverse:
Longitudinal:
CheckBox
TextView like the title bar effect
Other useful styles
For more details, refer to the R.attr class of the SDK documentation.
2.imageview.scaletype Property
The attribute of the ImageView is Android:scaletype, which is Imageview.setscaletype (Imageview.scaletype). Android:scaletype is a size that controls how the picture resized/moved to the ImageView. Imageview.scaletype/
The meaning difference of Android:scaletype value:
Center/center is centered on the original size of the image, and when the picture is longer/wider than the length/width of the view, the center portion of the image is displayed
Center_crop/centercrop proportionally enlarges the size of the image so that the image is long (wide) equal to or greater than the length (width) of the view
Center_inside/centerinside Displays the contents of the picture in full, by scaling it down or the original size to make the picture long/wide equal to or less than the length/width of the view
Fit_center/fitcenter enlarge/Shrink the picture to the width of the view, centered on the display
Fit_end/fitend Zoom in/out to the width of the view, displayed in the lower part of the view
Fit_start/fitstart enlarge/Shrink the image to the width of the view, displayed in the upper part of the view
Fit_xy/fitxy the picture is not scaled up/down to the view size display
Matrix/matrix using matrices to draw
3.screenOrientation screen settings (corresponding to activity settings in XML configuration file)
Note: Android only supports 270 degree rotation.
Android:screenorientation sets the direction of the activity, which can be any one of the following strings:
"Unspecified"
-Default value. The display direction is selected by the system. The different devices may vary.
"Landscape"
-Horizontal direction
"Portrait"
-Portrait
"User"
-User's current preferred direction
"Behind"
-the same direction as the activity under the activity stack
"Sensor"
-Determines the orientation according to the physical direction sensor. Depending on the direction the user is holding, when the user rotates the device, it changes.
"Nosensor"
-The direction is not determined by the physical direction sensor. The sensor is ignored, so when the user rotates the device, the display does not change. In addition to this distinction, the system chooses to use the same policy orientation for "unspecified" settings. The system selects the same display direction according to the "Unspecified" ("unspecified") setting.
3.1 Screen Toggle Code
Some programs are suitable to switch from vertical screen to horizontal screen, or vice versa, how to do this time? The following configuration android:screenorientation= "Portrait" can be configured where the activity is configured. This will ensure that the vertical screen is always vertical, or landscape landscape. And some programs are suitable for the screen switch. How to deal with it? The first thing to do when configuring activity is to configure the following: android:configchanges= "keyboardhidden|orientation", You also need to rewrite the activity's Onconfigurationchanged method. The implementation is as follows, do not need to do too much content:
When you turn the screen, remember the current configuration so that no new activity is restarted each time you turn the screen, and the current video will continue to appear
onConfigurationChangedif(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){ // landscape do nothing is ok }else if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){ // portrait do nothing is ok } }
4. Layout distribution
A: Different layout Android phone screen size varies, there are 480x320, 640x360, 800x480. How can I make the app adapt to different screens? In fact, it is very simple to create a different layout folder in the Res directory, such as layout-640x360,layout-800x480, All layout files are written to R.java after compilation, and the system uses the appropriate layout according to the size of the screen.
II: HDPI, MDPI, ldpi in the previous version, there was only one drawable, while the 2.1 version had drawable-mdpi, drawable-ldpi, drawable-hdpi Three, these three are mainly to support multi-resolution. The difference between drawable-hdpi, drawable-mdpi and drawable-ldpi: (1) drawable-hdpi contains high-resolution images, such as WVGA (480x800), FWVGA (480x854) (2) DRAWABLE-MDPI contains medium-resolution images such as HVGA (320x480) (3) drawable-ldpi with low-resolution images, such as QVGA (240x320) The system will be based on the resolution of the machine to each of these folders to find the corresponding picture.
5. When playing video, it will not darken
Android
Prevent the system from hibernation, so that the screen does not dim, keep the game in the screen highlighting the way to achieve this function is two, one is in the Manifest.xml file inside the declaration, one is in the code to modify the LAYOUTPARAMS flag bit. Specific as follows:
1, in the Manifest.xml file with user-permission declaration. The code is as follows:
This way, when you install the APK, the system prompts the installer to allow the Disable hibernation feature to be used.
2, in the program with code implementation. The code is as follows:
To add this code to Setcontentview (R.layout.main) before
This method, when installed, does not prompt the installer to allow the use of the Disable hibernation function