Android FAQs and Development Experience Summary (III)

Source: Internet
Author: User

1. Space-occupying style issues

Number, letter, and character blending placeholder problems: full-width of numbers and letters. Since most of the time our input is half-width, the placeholder for letters and numbers cannot be determined, but once full-width, the digits and the letters occupy the same position as a Chinese character, which avoids the typographical problems caused by the occupying position.

2. Slightly complex layout with relativelayout layout to debug more convenient and concise

< Span style= "Color:rgb (51,51,51); font-family: Microsoft Ya-Black, Helvetica,sans-serif,verdana, ' Ms Song ', song Body, Arial; line-height:24px ">3. Sub-layout when   use Android:layout_weight or tablelayout to create distribution boards

< Span style= "Color:rgb (51,51,51); font-family: Microsoft Ya-Black, Helvetica,sans-serif,verdana, ' Ms Song ', song Body, Arial; line-height:24px ">4. English document typesetting: TextView to maintain the integrity of the word when it wraps, the solution is to calculate the length of the string, and then manually set how many letters each line displays and add ' \ n '.

< Span style= "Color:rgb (51,51,51); font-family: Microsoft Ya-Black, Helvetica,sans-serif,verdana, ' Ms Song ', song Body, Arial; line-height:24px ">5. Do not take time-consuming actions in the main thread such as: Database operation file operation   Request Server operation, etc.

< Span style= "Color:rgb (51,51,51); font-family: Microsoft Ya-Black, Helvetica,sans-serif,verdana, ' Ms Song ', song Body, Arial; line-height:24px ">6. styles.xml: Distill the constantly reproduced style from layout into a common style generic component and put it in Styles.xml.

Special usage of 7.string.xml

For example, "I am 23 years old this year", this 23 is the integer type. In the String.xml can write this, <string name= "old" > I%1$d years of age </string>

< Span style= "Color:rgb (51,51,51); font-family: Microsoft Ya-Black, Helvetica,sans-serif,verdana, ' Ms Song ', song Body, Arial; line-height:24px "> /p>

<span style= "FONT-SIZE:14PX;" ><pre name= "code" class= "java" >string Sageformat = Getresources (). getString (r.string.old);  String sfinalage = String.Format (Sageformat, 23°c);  </span>

Label Description:
%n$ms: Represents the output of a string, n is the number of parameters, set the value of M can be placed before the output space
%N$MD: Represents the output is an integer, n is the number of parameters, set the value of M can be placed before the output space, can also be set to 0m, before the output of M 0
%N$MF: Represents the output is a floating-point number, n is the number of parameters, setting the value of M can control the scale, such as m=2.2, the output format is 00.00

can also be simply written as:

%d (represents an integer)

%f (indicates floating point number)

%s (representing string)

Android FAQs and Development Experience Summary (III)

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.