小程序建站公司网站企业
- 作者: 五速梦信息网
- 时间: 2026年04月20日 07:10
当前位置: 首页 > news >正文
小程序建站公司,网站企业,海外网站空间,app开发源码TextView
TextView类是View的直接子类#xff0c;用于单纯地显示一行或多行静态文本的视图。它继承View所有XML属性#xff0c;并有着自己的XML属性。
在XM布局中常用的属性:
属性说明android:autoLink设置文本超链接样式#xff0c;并点击跳向链接#xff0c;值#x…TextView
TextView类是View的直接子类用于单纯地显示一行或多行静态文本的视图。它继承View所有XML属性并有着自己的XML属性。
在XM布局中常用的属性:
属性说明android:autoLink设置文本超链接样式并点击跳向链接值none 不匹配任何类型的文字(默认) web 匹配URL地址单击后打开浏览器显示地址email 匹配邮箱地址单击后打开邮箱发送邮件phone 匹配电话号码单击后打开拔号界面map 匹配地图地址,单击后打开地图选项all 匹配所有的格式,自动检测web、phone、email和map四种格式android:autoText是否使用自动拼写帮助默认falseandroid:cursorVisible设定光标为显示/隐藏默认trueandroid:digits设置允许输入哪些字符默认falseandroid:drawableBottom在控件下方绘制一个drawable这里可以是图片引用、颜色这里如果是颜色的话会把文本背景设为该颜色并且如果同时和background使用时会覆盖后者android:drawableEnd在控件结尾处绘制一个drawableandroid:drawableLeft在控件左边处绘制一个drawableandroid:drawablePadding设置文本与drawable(图片)的间隔与drawableLeft、drawableRight、drawableTop、drawableBottom一起使用可设置为负数单独使用没有效果android:drawableRight在控件右边处绘制一个drawableandroid:drawableStart在控件开始处绘制一个drawableandroid:drawableTop在控件上方绘制一个drawableandroid:editable设置是否可编辑即EditViewandroid:ellipsize内容过长的时,显示带省略号值none、start、middle、end、marquee跑马灯android:ems设置控件的宽度为N个字符的宽度。这里测试为一个汉字字符宽度android:fontFamily设定文本的字体android:freezesText设置屏幕旋转后的文本是否保存文本的内容以及光标的位置默认falseandroid:gravity针对自身视图如何定位当前内容位置值top、bottom、left、right、center_vertical、fill_vertical、center_horizontal、fill_horizontal、centent、fill、clip_vertical、clip_horizontal、start、endandroid:height设置文本区域的高度android:hint文本为空时显示的文字水印提示信息android:imeOptions输入键盘确定铵钮类型在EditText中使用值actionNone回车键、actionGoGo 、actionSearch搜索 、actionSend发送 、actionNext下一步 和 actionDone确定/完成android:includeFontPadding置文本是否包含顶部和底部额外空白默认为trueandroid:inputMethod为文本指定输入法需要完全限定名(完整的包名)android:inputType设置文本的类型用于帮助输入法显示合适的键盘类型android:letterSpacing文本字母间距android:lineSpacingExtra设置行间距android:lineSpacingMultiplier设置行间距的倍数android:lines设置文本的行数android:linksClickable设置链接是否点击连接即使设置了autoLinkandroid:marqueeRepeatLimit在ellipsize属性指定marquee(跑马灯)情况下字幕动画重复滚动的次数android:maxHeight设置文本区域的最大高度android:maxLength限制显示的文本长度超出部分不显示android:maxLines设置文本的最大显示行数与width或者layout_width结合使用超出部分自动换行超出行数将不显示android:maxWidth设置文本区域的最大宽度android:minHeight设置文本区域的最小高度android:minLines设置文本的最小行数与lines类似android:minWidth设置文本区域的最小宽度android:numeric输入限制值integer输入是数字的、signed输入是数字的符号是允许的。、decimal输入数字、小数允许android:password输入密码专用输入字符显示为密码点android:phoneNumber设置为电话号码的输入方式android:privateImeOptions设置输入法选项android:scrollHorizontally设置文本超出TextView的宽度的情况下是否出现横拉条android:selectAllOnFocus如果文本是可选择的让他获取焦点而不是将光标移动为文本的开始位置或者末尾位置android:shadowColor指定文本阴影的颜色需要与shadowRadius一起使用android:shadowDx设置阴影横向坐标开始位置android:shadowDy设置阴影纵向坐标开始位置android:shadowRadius设置阴影的模糊半径。设置为0.1就变成字体的颜色了一般设置为3.0的效果比较好android:singleLine是否单行或者多行回车是离开文本框还是文本框增加新行android:text设置显示文本android:textAllCaps文本全部大写android:textAppearance设置文字外观基于文字的颜色typeface大小和样式android:textColor设置字体颜色android:textColorHighlight设置被选中文字的底色默认为蓝色android:textColorHint设置提示信息文字的颜色默认为灰色android:textColorLink链接的文本颜色android:textIsSelectable文本内容是否可选择android:textScaleX控制字与字之间的间距android:textSize设置文字大小android:textStyle设置字形值normal常规 、bold(粗体)、italic(斜体)。可以设置一个或多个用“|”隔开android:typeface设置文本字体值normal、sans、serif 、monospace(等宽字体)android:width设置文本区域的宽度
使用实例1 - 网址超链接
TextView android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:autoLinkwebandroid:textwww.csdn.net/使用实例2 - 显示图片和背景
TextViewandroid:idid/txt_backandroid:layout_widthwrap_contentandroid:layout_heightmatch_parentandroid:layout_alignParentLefttrueandroid:layout_centerVerticaltrueandroid:paddingLeft20dpandroid:paddingRight15dpandroid:backgrounddrawable/return_btn_bgandroid:drawableLeftdrawable/wallpaper_preview_back_selector/使用实例3 - 文字标签更丰富多采
TextView tvUserName (TextView)findViewById(R.id.tv_user_name);
String str font color#FF0000\你好/fontbrfont color#00FF00\安卓/font
tvUserName .setText(Html.formHtml(str));// 带图片——————————————————————-
TextView tvUserName (TextView)findViewById(R.id.tv_user_name);
String str h1测试图片 /h1 pimg src R.drawable.ic_launcher /p;
tvUserName .setText(Html.formHtml(str, imgGetter, null));ImageGetter imageGetter new Html.ImageGetter() {public Drawable getDrawable(String source) {int id Integer.parseInt(source);Drawable drawable getResources().getDrawable(id);return drawable;}
}Button
Button类是TextView的直接子类代表一个按钮控件。它继承View和TextView所有XML属性。
使用实例1 - XML中指定单击方法
Button android:layout_heightwrap_content android:textstring/self_destruct android:onClickselfDestruct /使用实例2 -代码中指定单击方法
Button button (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO… }
});EditText
EditText类是TextView的直接子类代码一个可编辑的文本框。它继承View和TextView所有XML属性。
使用实例
EditTextandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:hint请输入用户名 /
EditTextandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:maxLength10android:numericintegerandroid:passwrodtrueandroid:hint请输入密码 /使用实例2 - 字体设置
EditTextandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:typefacesans android:hint我的是字体是sans/
EditTextandroid:et_user_nameandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:hint我的是字体是华文行楷 /
// ——————————————————————-
EditText etUserName (EditText)findViewById(R.id.et_user_name);
Typeface typeFace Typeface.createFromAsset(getAssets(), fonts/ STXINGKA.TTF);
etUserName.setTypeface(typeFace);使用实例3 - 键盘按钮监听
EditTextandroid:idid/et_user_nameandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:singleLinetrueandroid:imeOptionsactionDone/
// ——————————————————————-
EditText etUserName (EditText)findViewById(R.id.et_user_name);
etUserName.setOnEditorActionListener(new TextView.OnEditorActionListener() {Overridepublic boolean onEditorAction(TextView v, int actionId, KeyEvent event) {if(actionId EditorInfo.IME_ACTION_DONE) {return true;}return false;}
});
CompoundButton
CompoundButton继承自Button类在这个类中封装了一个 checked属性用于判断按钮是否被选中状态这也是它与Button的不同。它的子类有CheckBox, RadioButton, Switch,ToggleButton等。
在XM布局中扩展的属性:
属性说明android:button按钮样式的扩展可以是资源的引用android:buttonTint按钮样式用到的颜色此值必须是一颜色值android:buttonTintMode按钮样式混合模式图形色彩值src_over、src_in、src_atop、multiply、screen、add
CheckBox
CheckBox类是继承于CompoundButton类而CompoundButton类继承于Button类代表一个复选框按钮控件。它继承View、TextView和CompoundButton所有XML属性。
使用实例
CheckBoxandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:buttondrawable/checkboxstyle android:text请勾选我/// checkboxstyle.xml——————————————————–
?xml version 1.0 encodingUTF-8 ?
selector xmlns:androidhttp://schemas.android.com/apk/res/androiditem android:state checktrue android:drawabledrawable/select /item android:state checkfale android:drawabledrawable/unselect /
/selector
- 上一篇: 小程序价格为什么比网站建设高购物网站优惠券怎么做
- 下一篇: 小程序建站哪家好找小程序开发公司
相关文章
-
小程序价格为什么比网站建设高购物网站优惠券怎么做
小程序价格为什么比网站建设高购物网站优惠券怎么做
- 技术栈
- 2026年04月20日
-
小程序济南优化专业的公司
小程序济南优化专业的公司
- 技术栈
- 2026年04月20日
-
小城市做网站嘉定网站设计制作优化排名
小城市做网站嘉定网站设计制作优化排名
- 技术栈
- 2026年04月20日
-
小程序建站哪家好找小程序开发公司
小程序建站哪家好找小程序开发公司
- 技术栈
- 2026年04月20日
-
小程序开发公司制作东莞网站建设优化诊断
小程序开发公司制作东莞网站建设优化诊断
- 技术栈
- 2026年04月20日
-
小程序开发平台哪家可信赖温州seo博客
小程序开发平台哪家可信赖温州seo博客
- 技术栈
- 2026年04月20日






