Android FAQ and development experience summary (3)

Source: Internet
Author: User

Android FAQ and development experience summary (3)

1. Space placeholder adjustment style problems

Number, letter, and Chinese Character Placement Problem: All numbers and letters are divided into different types. In most cases, because our input is half-width, the placeholder values of letters and numbers cannot be determined. However, once fully divided, the placeholder values of numbers and letters are the same as those of a Chinese character, in this way, the layout problem caused by placeholder can be avoided.

2. more convenient and concise debugging of a slightly Complex layout with RelativeLayout Layout

3. Use android: layout_weight or TableLayout to create an equal-score layout during the same-score layout.

4. English Document Layout: When textview is automatically changed, the word integrity should be maintained. The solution is to calculate the string length, and then manually set the number of letters displayed in each row with '\ n' added '.

5. Do not perform time-consuming operations in the main thread, for example, database operation File Operation Request server operation.

6. styles. xml: extract the styles that are repeatedly reproduced in layout to a common style component and put it in styles. xml.

7. Special usage of string. xml

For example, "I am 23 years old this year", and this 23 is an integer. This can be written in string. xml, I'm % 1 $ d this year

 

 
String sAgeFormat = getResources().getString(R.string.old); String sFinalAge = String.format(sAgeFormat, 23); 

 

Label introduction:
% N $ ms: indicates that the output is a string, and n indicates the number of parameters. The m value can be set with spaces before the output.
% N $ md: indicates that the output is an integer, and n indicates the number of parameters. To set m, you can place a space before the output, or set it to 0 m, put m 0 before output
% N $ mf: indicates that the output is a floating point number, and n indicates the number of parameters. Setting the m value can control the number of decimal places. For example, when m = 2.2, the output format is 00.00.

You can also write it as follows:

% D (integer)

% F (floating point number)

% S (string)

 

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.