Android Configuration introduction (unfinished), android Introduction

Source: Internet
Author: User

Android Configuration introduction (unfinished), android Introduction

The blog is very empty. I want to enter an article quickly. It is not very common to read this topic on the Chinese network. However, because I do not know all the configurations, I need to verify the ideas, it is also very slow to write, and a seat is not completed first.

Configuration refers to Configuration. the Configuration information represented by the java class is located in ($ ANDROID_ROOT)/frameworks/base/core/java/android/content/res/Configuration. java

This article consists of three parts:

   

1. Explain the member variables one by one to understand the functions and meanings of each value;

   

2. Pursue the configuration initialization and use process;

   

3. Summary how to configure these values as a maintainer of the Android platform.

 

I. member variables

Public intDensityDpi// The target screen density being rendered to, corresponding to density resource qualifier.

Currently, it is generally a three-digit 10-digit number, corresponding:

  • 120 –> ldpi: Low-density screens.
  • 160 –> mdpi: Medium-density (on traditional HVGA) screens.
  • 240 –> hdpi: High-density screens.
  • 320 –> xhdpi: Extra high-density screens.

There are larger xxhdpi (480) and xxxhdpi (640). The larger the densityDpi, the higher the screen resolution (dpi, dot per inch) of the current device, the densityDpi of a device is determined by the dpi of the device screen when it is released. Suppose I have an MX3, 1800 × 1080 resolution, 5.1 inches, in this case, the dpi is the number of pixel points in the diagonal line divided by 5.1 to approximately 411.6. I set densityDpi TO THE xxhdpi closest to 411.6. It enables apps to dynamically decide the resources to be loaded through densityDpi without knowing the screen size and resolution of each Android device, so as to adapt to these devices.

For example, dp is generally used as the Unit during UI painting, and the system will help to zoom in and zoom in to the same size visually on devices with different resolutions; however, pixel is used as the unit only to set the pixel size. Views of the same pixel size are relatively small visually on high-resolution devices. Here we will use the pixel and dp transformations:

   

dp= px*160/densityDpi;

In addition, the res directory of the app contains some drawable-mdpi/drawable-hdpi/drawable-xhdpi, which is also determined by densityDpi. Of course, the classification of these directories is more complex, I will not talk about it here.

 

Public floatFontScale// Current user preference for the scaling factor for fonts, relative to the base density scaling.

Public int hardKeyboardHidden

A flag indicating whether the hard keyboard has been hidden.

Public int keyboard

The kind of keyboard attached to the device.

Public int keyboardHidden

A flag indicating whether any keyboard is available.

Public Locale locale

Current user preference for the locale, corresponding to locale resource qualifier.

Public int mcc

Imsi mcc (Mobile Country Code), corresponding to mcc resource qualifier.

Public int mnc

Imsi mnc (Mobile Network Code), corresponding to mnc resource qualifier.

Public int navigation

The kind of navigation method available on the device.

Public int navigationHidden

A flag indicating whether any 5-way or DPAD navigation available.

Public int orientation

Overall orientation of the screen.

Public int screenHeightDp

The current height of the available screen space, in dp units, corresponding to screen height resource qualifier.

Public int screenLayout

Bit mask of overall layout of the screen.

Public int screenWidthDp

The current width of the available screen space, in dp units, corresponding to screen width resource qualifier.

Public int smallestScreenWidthDp

The smallest screen size an application will see in normal operation, corresponding to smallest screen width resource qualifier.

Public int touchscreen

The kind of touch screen attached to the device.

Public int uiMode

Bit mask of the ui mode.


In android programming, the eclipse run as is not easy to use. Only the configuration is displayed and cannot be automatically bound to the simulator prawns.

Oh, this problem, because you started it twice. At the first startup, the android simulator will install your api, which is the hello world Program, you disabled the android simulator at this time, modified your program to hellowold, and then run it. At this time, the simulator was installed because the first api was the application with spaces, therefore, the second installation won't succeed, so it won't run. If you don't close the android simulator, but directly modify and run it, this problem won't occur, the solution is to delete the api that has been installed in the simulator, and then run your second helloworld without spaces.


How many times does the android screen translation listener call public void onConfigurationChanged (Configuration config?

Let's take a look at this. My summary: Precautions for horizontal and vertical screen cutting for Android
Hi.baidu.com/..e.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.