Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of TextView and its subclasses in Android

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly talks about "TextView and its subclass analysis in Android". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "TextView and its subclass Analysis in Android".

TextView directly inherits View and is also the parent of two UI component classes, EditText and Button. As the name implies, text boxes display text on the page. In this sense, they are similar to JLabel of Swing in Java.

Functionally, TextView is actually a text editor, but Android turns off its text editing function. If you need to edit the text box of the content, you can use its subclass EditText.

TestView provides a large number of XML attributes, most of which can also be applied to its subclasses. Here are some commonly used XML attributes

Android:aotuLink, related method: setAutoLinkMask (int), whether to convert text in accordance with the specified format into a stand-alone hyperlink form

Android:cursorVisble, related method: setCursorVisible (boolean), sets whether the cursor of the text box is visible

Android:drawbleBottom, related method: setCompoundDrawablesWithIntrinsicBounds, draw the specified figure at the bottom of the text box

Android:drawbleEnd, related method: setCompoundDrawablesWithIntrinsicBounds, draw the specified figure at the end of the text box

Android:drawbleLeft, related method: setCompoundDrawablesWithIntrinsicBounds, draw the specified figure on the left side of the text box

Android:editable, which sets whether the text runs editing

Android:gravity, related method: setGravity (int), sets the alignment of the text in the text box

Android:password, related method: setTransformationMethod (), set the text box to a password box

.

Button (button)

Button inherits from TextView, mainly produces a button for the user to click on in the UI interface, and initiates an onClick event when the user clicks the button.

Radio (checkbox) and CheckBox (checkbox)

Inherit from Button, so you can use various properties and methods of Button directly

ToggleButton (status switch button) and Switch (switch)

These two buttons are also inherited from Button, and they look very similar to CheckBox, but in fact, ToggleButton (state switch button) and Switch (switch) are represented as some kind of state, and they have supported XML properties, such as

Android:checked, related method: setChecked (boolean), sets whether the button is selected or not

Android:textStyle, related method: setSwitchTypeface (Typaface), set the text style of the switch

.

AnalogClock and TextClock

The clock UI component is two very simple components. TextClock is based on TextView, that is to say, the text itself is only showing time. AnalogClock is based on View, overrides the OnDraw method, and will draw an analog clock on View.

At this point, I believe you have a deeper understanding of "TextView and its subclass analysis in Android". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report