Because of the screen limitations, applications that use text need to take some steps to keep typography readable and flexible for different screens. Note how the TextView controls display under these conditions.Īndroid devices come in all shapes and sizes and Android users have different needs in terms of application accessibility, such as the need for larger font sizes. In the first figure, the user has a Normal font preference, and in the second figure, the user has a Huge font preference. Now let's pull everything together and show you what all these different TextView controls would look like on an Ice Cream Sandwich-style device. The following XML defines three TextView controls, one that will be displayed using the Small font, one in the Medium font, and the third in the Large font size. These font sizes are built upon the SP unit type, so they will scale with user preferences. The Android platform defines a set of relative font size styles that you can use in your applications: Small, Medium, and Large. The text displayed by this control will not scale based on the user's preferences or other factors. Here's an example of a TextView that defines its size in terms of PX units. Simply use one of the absolute units, such as the PX (pixels). While this is discouraged, as it may make font sizes unreadable on some devices, here's how you can do it if you have a good reason for doing so. There may be some situations when you do not want your text to scale or change size. When you don't want your text to scale no matter what, use absolute pixel sizes with the px unit. In this case, you'd use the DP unit, as it scales in pixels with the density of the device, but not with user settings. When it comes to title or heading text, and not text in a free flowing text box, you may not want the user to be able to control the size of the text. Here's an example of a TextView that defines its size in terms of SP units: The SP unit is perfect for text sizes, as it is sensitive to the user's display settings. When it comes to text sizes, you will want to use density-independent units like DP (device-independent pixels) and SP. The Android platform allows dimensional values to be defined in a variety of ways. When you want your text to be flexible, based on the user preferences, defne text font sizes using SP (scalable point) units. The user font preference can be set to make text one of four font size settings (Small, Normal, Large, and Huge), as shown in Figure 1. To change the font settings on the device, launch the Settings application, then choose Display, Font Size. The Android operating system recognizes this fact and provides accessibility features to allow the device text font size to be scaled based on the user's preference. Some users have great eyesight and others literally nearly blind. In this quick tutorial, we will discuss some of the steps that developers can take to make the text in their applications clear and readable, as well as flexible enough to work on a variety of screen types and across multiple user display settings. By using some simple methods, developers can write one application whose text will display reasonably well for all sorts of devices, including supporting the user's own text size preferences, with little extra work. Android developers often include text in their applications that needs to be readable, regardless of what device the application is running on. Android device screens come in all shapes and sizes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |