android widget(1)

Anroid  widget 组件

http://developer.android.com/resources/tutorials/views/index.html

这个地方讲解的比较好

The widget package contains (mostly visual) UI elements to use on your Application screen

这里面包含的都是些Ui 元素。

一、button 组件

1:所在包  :android.widget.Button;

2:英文解释:

Button represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action. A typical use of a push-button in an activity would be the following

public class MyActivity extends Activity {

     protected void onCreate(Bundle icicle) {

         super.onCreate(icicle);

         setContentView(R.layout.content_layout_id);

         final Button button = (Button) findViewById(R.id.button_id);

         button.setOnClickListener(new View.OnClickListener() {

             public void onClick(View v) {

                 // Perform action on click

             }

         });

     }

 }

可以看出给按钮编辑事件 ,要有一个 Button 得到按钮的实例,然后 调用setOnClickListener 方法写具体的代码。

3:构造函数

 

publicButton (Context context)

publicButton (Context context, AttributeSet attrs)

publicButton (Context context, AttributeSet attrs, int defStyle)

TextView 组件

1:包位置:android.widget.TextView

2SDK解释:

Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing. 

PS: 这个一般不允许编辑的,向但与 Lable标签,可以显示内容的 ,我们也可以在程序里面动态的改变界面上显示的东西。

3:属性

下面的我感觉重要的 都加上了底色,里面 有些地方我翻译过来了 。

XML Attributes

Attribute Name

Related Method

Description

android:autoLink

setAutoLinkMask(int)

Controls whether links such as urls and email addresses are automatically found and converted to clickable links. 

android:autoText

setKeyListener(KeyListener)

If set, specifies(说明) that this TextView has a textual( 原文的、原版的) input method and automatically corrects some common spelling errors. PS:如果设置的话,会有一个默认的输入法,帮助修改拼写错误)

android:bufferType

setText(CharSequence,TextView.BufferType)

Determines the minimum type that getText() will return. 

android:capitalize

setKeyListener(KeyListener)

If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. PS吧用户输入的东西自动的转化成大写字母

android:cursorVisible

setCursorVisible(boolean)

Makes the cursor visible (the default) or invisible 

Must be a boolean value, either "true" or "false". 

android:digits(数字)

setKeyListener(KeyListener)

If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. (如果设置只可以输入数字)

android:drawableBottom

setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable)

The drawable to be drawn below the text. 

android:drawableLeft

setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable)

The drawable to be drawn to the left of the text. 

android:drawablePadding

setCompoundDrawablePadding(int)

The padding between the drawables and the text. 

android:drawableRight

setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable)

The drawable to be drawn to the right of the text. 

android:drawableTop

setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable)

The drawable to be drawn above the text. 

android:editable

If set, specifies that this TextView has an input method. 

android:editorExtras

setInputExtras(int)

Reference to an <input-extras> XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. 

android:ellipsize

setEllipsize(TextUtils.TruncateAt)

If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. 如果字数较多变形,而不是不居中

android:ems

setEms(int)

Makes the TextView be exactly this many ems wide 

Must be an integer value, such as "100". 

android:freezesText

setFreezesText(boolean)

If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. (不仅保持文字而且保持元数据,比如光标的位置)

android:gravity

setGravity(int)

Specifies how to align the text by the view's x and/or y axis when the text is smaller than the view.(当文本比组件小的时候, 如何和组件的X/Y轴 对齐) 

android:height

setHeight(int)

Makes the TextView be exactly this many pixels tall. 

android:hint

setHint(int)

Hint text to display when the text is empty. (当标签是空的时候,在标签中显示什么数据)

android:imeActionId

setImeActionLabel(CharSequence,int)

Supply a value for EditorInfo.actionId used when an input method is connected to the text view. 

android:imeActionLabel

setImeActionLabel(CharSequence,int)

Supply a value for EditorInfo.actionLabel used when an input method is connected to the text view. 

android:imeOptions

setImeOptions(int)

Additional features you can enable in an IME associated with an editor, to improve the integration with your application. 

android:includeFontPadding

setIncludeFontPadding(boolean)

Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. 

android:inputMethod

setKeyListener(KeyListener)

If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). 

android:inputType

setRawInputType(int)

The type of data being placed in a text field, used to help an input method decide how to let the user enter text. 

android:lineSpacingExtra

setLineSpacing(float,float)

Extra spacing between lines of text. (行间距)

android:lineSpacingMultiplier

setLineSpacing(float,float)

Extra spacing between lines of text, as a multiplier. (行间距)倍数

android:lines

setLines(int)

Makes the TextView be exactly this many lines tall 

Must be an integer value, such as "100". 

android:linksClickable

setLinksClickable(boolean)

If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found. (设置连接是否可用)

android:marqueeRepeatLimit

setMarqueeRepeatLimit(int)

The number of times to repeat the marquee animation. (来回滚动的次数)

android:maxEms

setMaxEms(int)

Makes the TextView be at most this many ems wide 

Must be an integer value, such as "100". 

android:maxHeight

setMaxHeight(int)

Makes the TextView be at most this many pixels tall 

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 

android:maxLength

setFilters(InputFilter)

Set an input filter to constrain the text length to the specified number. 

android:maxLines

setMaxLines(int)

Makes the TextView be at most this many lines tall 

Must be an integer value, such as "100". 

android:maxWidth

setMaxWidth(int)

Makes the TextView be at most this many pixels wide 

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 

android:minEms

setMinEms(int)

Makes the TextView be at least this many ems wide 

Must be an integer value, such as "100". 

android:minHeight

setMinHeight(int)

Makes the TextView be at least this many pixels tall 

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 

android:minLines

setMinLines(int)

Makes the TextView be at least this many lines tall 

Must be an integer value, such as "100". 

android:minWidth

setMinWidth(int)

Makes the TextView be at least this many pixels wide 

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 

android:numeric

setKeyListener(KeyListener)

If set, specifies that this TextView has a numeric input method. 

android:password

setTransformationMethod(TransformationMethod)

Whether the characters of the field are displayed as password dots instead of themselves. (是否是以密码的方式显示)

android:phoneNumber

setKeyListener(KeyListener)

If set, specifies that this TextView has a phone number input method. 

android:privateImeOptions

setPrivateImeOptions(String)

An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. 

android:scrollHorizontally

setHorizontallyScrolling(boolean)

Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). (在文字较多的情况下是否允许滚动)

android:selectAllOnFocus

setSelectAllOnFocus(boolean)

If the text is selectable, select it all when the view takes focus instead of moving the cursor to the start or end. (如果选择是否选择所有)

android:shadowColor

setShadowLayer(float,float,float,int)

Place a shadow of the specified color behind the text. (如果有颜色是否显示影印)

android:shadowDx

setShadowLayer(float,float,float,int)

Horizontal offset of the shadow. 

android:shadowDy

setShadowLayer(float,float,float,int)

Vertical offset of the shadow. 

android:shadowRadius

setShadowLayer(float,float,float,int)

Radius of the shadow. 

android:singleLine

setTransformationMethod(TransformationMethod)

Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. 

android:text

setText(CharSequence)

Text to display. 

android:textColor

setTextColor(ColorStateList)

Text color. 

android:textColorHighlight

setHighlightColor(int)

Color of the text selection highlight. 

android:textColorHint

setHintTextColor(int)

Color of the hint text. (提示文字)

android:textColorLink

setLinkTextColor(int)

Text color for links. 

android:textScaleX

setTextScaleX(float)

Sets the horizontal scaling factor for the text 

Must be a floating point value, such as "1.2". 

android:textSize

setTextSize(float)

Size of the text. 

android:textStyle

setTypeface(Typeface)

Style (bold, italic, bolditalic) for the text. 

android:typeface

setTypeface(Typeface)

Typeface (normal, sans, serif, monospace) for the text. 

android:width

setWidth(int)

Makes the TextView be exactly this many pixels wide. 

4: 构造函数

Public Constructors

TextView(Context context)

TextView(Context context, AttributeSet attrs)

TextView(Context context, AttributeSet attrs, int defStyle)

5:重要函数:

Public Methods

 

public voidaddTextChangedListener (TextWatcher watcher)

Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.

In 1.0, the afterTextChanged(Editable) method was erroneously not called after setText(char[], int, int) calls. Now, doing setText(char[], int, int) if there are any text changed listeners forces the buffer type to Editable if it would not otherwise be and does call this method.

public final voidappend (CharSequence text)

Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.

如果 控件不可以编辑就先放入到缓冲区里面

public int

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值