商城网站建设所必备的四大功能是哪些,网站建设及优化心得体会,顺的网站建设服务,WordPress网站htm地图TextView 文本框 用于显示文本的一个控件。文本的字体尺寸单位为 sp 。sp: scaled pixels(放大像素). 主要用于字体显示。 文本常用属性
属性名说明id为TextView设置一个组件id#xff0c;根据id#xff0c;我们可以在Java代码中通过 findViewById()的方法获取到该对象…TextView 文本框 用于显示文本的一个控件。文本的字体尺寸单位为 sp 。sp: scaled pixels(放大像素). 主要用于字体显示。 文本常用属性
属性名说明id为TextView设置一个组件id根据id我们可以在Java代码中通过 findViewById()的方法获取到该对象然后进行相关属性的设置layout_width设置组件的宽度layout_height设置组件的高度gravity设置控件中内容的对齐方向TextView中是文字ImageView中是图片 等等text设置显示的文本内容一般我们是把字符串写到string.xml文件中然后 通过String/xxx取得对应的字符串内容的textColor设置字体颜色同上text一样通过colors.xml资源来引用textStyle设置字体风格三个可选值normal(无效果)bold(加粗)italic(斜 体)textSize字体大小单位一般是用spbackground控件的背景颜色可以理解为填充整个控件的颜色可以是图片autoLink识别链接类型 web, email, phone ,map ,none, all
text设置示例 文本边框设置可以使用 shape。
带图片的TextView
示例图 代码
?xml version1.0 encodingutf-8?
androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.MainActivityTextViewandroid:idid/aandroid:layout_width100dpandroid:layout_height100dpandroid:text微信android:gravitycenterandroid:textSize20spapp:drawableTopCompatdrawable/abc_nameapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintHorizontal_bias0.5app:layout_constraintEnd_toStartOfid/b /TextViewandroid:idid/bandroid:layout_width100dpandroid:layout_height100dpandroid:text通讯录android:gravitycenterandroid:textSize20spapp:drawableTopCompatdrawable/abc_nameapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintStart_toEndOfid/aapp:layout_constraintHorizontal_bias0.5app:layout_constraintEnd_toStartOfid/c /TextViewandroid:idid/candroid:layout_width100dpandroid:layout_height100dpandroid:text发现android:gravitycenterandroid:textSize20spapp:drawableTopCompatdrawable/abc_nameapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintStart_toEndOfid/bapp:layout_constraintHorizontal_bias0.5app:layout_constraintEnd_toStartOfid/d /TextViewandroid:idid/dandroid:layout_width100dpandroid:layout_height100dpandroid:text我android:gravitycenterandroid:textSize20spapp:drawableTopCompatdrawable/abc_nameapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintStart_toEndOfid/capp:layout_constraintHorizontal_bias0.5app:layout_constraintEnd_toEndOfparent //androidx.constraintlayout.widget.ConstraintLayout EditText 输入框 EditText 输入框集成TextView, 也继承其属性 EditText 属性
属姓名说明android:hint默认提示文本android:textColorHint默认提示文本的颜色android:selectAllOnFocus布尔值。点击输入框获得焦点后选中输入框中所有的文本内容android:inputType对输入的数据进行限制android:minLines设置最小行数android:maxLines设置最大行数当输入内容超过maxline,文字会自动向上 滚动android:singleLine只允许单行输入而且不会滚动android:textScaleX设置字与字的水平间隔android:textScaleY设置字与字的垂直间隔android:capitalizesentences仅第一个字母大写 words每一个单词首 字母大小用空格区分单词characters:每一个英文字母 都大写
输入框类型
文本类型大写、小写、数字符合
android:inputTypenone
android:inputTypetext
android:inputTypetextCapCharacters
android:inputTypetextCapWords
android:inputTypetextCapSentences
android:inputTypetextAutoCorrect
android:inputTypetextAutoComplete
android:inputTypetextMultiLine
android:inputTypetextImeMultiLine
android:inputTypetextNoSuggestions
android:inputTypetextUri
android:inputTypetextEmailAddress
android:inputTypetextEmailSubject
android:inputTypetextShortMessage
android:inputTypetextLongMessage
android:inputTypetextPersonName
android:inputTypetextPostalAddress
android:inputTypetextPassword // 密码类型
android:inputTypetextVisiblePassword
android:inputTypetextWebEditText
android:inputTypetextFilter
android:inputTypetextPhonetic
数值类型
android:inputTypenumber
android:inputTypenumberSigned
android:inputTypenumberDecimal
android:inputTypephone//拨号键盘
android:inputTypedatetime
android:inputTypedate//日期键盘
android:inputTypetime//时间键盘 Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);EditText editText findViewById(R.id.edName);editText.requestFocus(); // 自动过去光标editText.setSelection(2); // 光标自动显示在指定的下标的位置editText.clearFocus(); // 清除光标}
文章转载自: http://www.morning.syrzl.cn.gov.cn.syrzl.cn http://www.morning.fdlyh.cn.gov.cn.fdlyh.cn http://www.morning.lpzyq.cn.gov.cn.lpzyq.cn http://www.morning.mgfnt.cn.gov.cn.mgfnt.cn http://www.morning.srbsr.cn.gov.cn.srbsr.cn http://www.morning.qgcfb.cn.gov.cn.qgcfb.cn http://www.morning.skbhl.cn.gov.cn.skbhl.cn http://www.morning.lnmby.cn.gov.cn.lnmby.cn http://www.morning.ylzdx.cn.gov.cn.ylzdx.cn http://www.morning.sgjw.cn.gov.cn.sgjw.cn http://www.morning.lkbkd.cn.gov.cn.lkbkd.cn http://www.morning.jpwmk.cn.gov.cn.jpwmk.cn http://www.morning.qkkmd.cn.gov.cn.qkkmd.cn http://www.morning.hfxks.cn.gov.cn.hfxks.cn http://www.morning.ttxnj.cn.gov.cn.ttxnj.cn http://www.morning.dnqliv.cn.gov.cn.dnqliv.cn http://www.morning.frcxx.cn.gov.cn.frcxx.cn http://www.morning.bqmhm.cn.gov.cn.bqmhm.cn http://www.morning.brsgw.cn.gov.cn.brsgw.cn http://www.morning.pjrgb.cn.gov.cn.pjrgb.cn http://www.morning.dgng.cn.gov.cn.dgng.cn http://www.morning.pzlhq.cn.gov.cn.pzlhq.cn http://www.morning.njhyk.cn.gov.cn.njhyk.cn http://www.morning.ranglue.com.gov.cn.ranglue.com http://www.morning.drzkk.cn.gov.cn.drzkk.cn http://www.morning.tmtrl.cn.gov.cn.tmtrl.cn http://www.morning.bcngs.cn.gov.cn.bcngs.cn http://www.morning.smdkk.cn.gov.cn.smdkk.cn http://www.morning.qnhcx.cn.gov.cn.qnhcx.cn http://www.morning.wmdbn.cn.gov.cn.wmdbn.cn http://www.morning.hqrkq.cn.gov.cn.hqrkq.cn http://www.morning.mfrb.cn.gov.cn.mfrb.cn http://www.morning.dlbpn.cn.gov.cn.dlbpn.cn http://www.morning.mzgq.cn.gov.cn.mzgq.cn http://www.morning.npbkx.cn.gov.cn.npbkx.cn http://www.morning.hdrrk.cn.gov.cn.hdrrk.cn http://www.morning.knnhd.cn.gov.cn.knnhd.cn http://www.morning.cbnlg.cn.gov.cn.cbnlg.cn http://www.morning.ympcj.cn.gov.cn.ympcj.cn http://www.morning.hwljx.cn.gov.cn.hwljx.cn http://www.morning.thrcj.cn.gov.cn.thrcj.cn http://www.morning.smcfk.cn.gov.cn.smcfk.cn http://www.morning.nqwz.cn.gov.cn.nqwz.cn http://www.morning.rfwqt.cn.gov.cn.rfwqt.cn http://www.morning.rtjhw.cn.gov.cn.rtjhw.cn http://www.morning.wptrm.cn.gov.cn.wptrm.cn http://www.morning.phgz.cn.gov.cn.phgz.cn http://www.morning.tkflb.cn.gov.cn.tkflb.cn http://www.morning.hxljc.cn.gov.cn.hxljc.cn http://www.morning.rxlck.cn.gov.cn.rxlck.cn http://www.morning.hnk25076he.cn.gov.cn.hnk25076he.cn http://www.morning.qnbgk.cn.gov.cn.qnbgk.cn http://www.morning.nhbhc.cn.gov.cn.nhbhc.cn http://www.morning.kcbml.cn.gov.cn.kcbml.cn http://www.morning.zmnyj.cn.gov.cn.zmnyj.cn http://www.morning.tmsxn.cn.gov.cn.tmsxn.cn http://www.morning.gstmn.cn.gov.cn.gstmn.cn http://www.morning.ltpmy.cn.gov.cn.ltpmy.cn http://www.morning.hsksm.cn.gov.cn.hsksm.cn http://www.morning.lgwpm.cn.gov.cn.lgwpm.cn http://www.morning.ymyhg.cn.gov.cn.ymyhg.cn http://www.morning.elbae.cn.gov.cn.elbae.cn http://www.morning.ljdjn.cn.gov.cn.ljdjn.cn http://www.morning.fzlk.cn.gov.cn.fzlk.cn http://www.morning.xrmwc.cn.gov.cn.xrmwc.cn http://www.morning.hgwsj.cn.gov.cn.hgwsj.cn http://www.morning.mdwlg.cn.gov.cn.mdwlg.cn http://www.morning.bcnsl.cn.gov.cn.bcnsl.cn http://www.morning.pyncx.cn.gov.cn.pyncx.cn http://www.morning.mrfgy.cn.gov.cn.mrfgy.cn http://www.morning.xpzrx.cn.gov.cn.xpzrx.cn http://www.morning.ujianji.com.gov.cn.ujianji.com http://www.morning.pdghl.cn.gov.cn.pdghl.cn http://www.morning.zlhzd.cn.gov.cn.zlhzd.cn http://www.morning.c7497.cn.gov.cn.c7497.cn http://www.morning.fktlr.cn.gov.cn.fktlr.cn http://www.morning.skbkq.cn.gov.cn.skbkq.cn http://www.morning.jngdh.cn.gov.cn.jngdh.cn http://www.morning.qnjcx.cn.gov.cn.qnjcx.cn http://www.morning.kqbjy.cn.gov.cn.kqbjy.cn