Analysis of Android Development Optimization: detailed explanation of interface UI optimization (I)

Usually, many controls and resources are used in this page. The Android system itself has many resources, including various strings, pictures, animations, styles and layouts, which can be used directly in applications. This has many advantages. It can not only reduce the use of memory, but also reduce part of the workload, but also reduce the size of the program installation package.

The following describes how to use system resources from several aspects.

1) Using system defined IDS

For example, we have an XML file defining listview. Generally, we will write code fragments like the following.

2) Using the picture resources of the system

Suppose we define a menu in the application, and the XML file is as follows.

One of the advantages of this is that the artist does not need to make an existing picture repeatedly, which can save a lot of working hours; The other is to ensure that the style of our application is consistent with the system.

Suppose we want to implement a dialog with "OK" and "Cancel" buttons on it. You can use the following code to directly use the string provided by the Android system.

4) Using the style of the system

Suppose there is a textview in the layout file to display the title of the window, using a medium font. You can use the following code snippet to define the style of textview.

5) Use the color definition of the system

In addition to the above system resources, you can also use the system defined colors. The most commonly used in projects is the use of transparent colors. The code snippet is as follows.

Experience sharing:

The Android system itself has many resources that can be used directly in applications. Specifically, you can view them in the corresponding folder of Android SDK. For example, you can enter $Android SDK $\ platforms \ android-8 \ data \ res to have a panoramic view of system resources.

Developers need to spend some time getting familiar with these resources, especially picture resources and various style resources, so that they can think of relevant resources and use them directly in the development process.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>