首页 > 其他分享 >【转】Android字体小结

【转】Android字体小结

时间:2023-06-13 22:37:48浏览次数:40  
标签:显示 text 字体 设置 Android 文本 小结 android TextView


 

android:autoLink  设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接。可选值(none/web/email/phone/map/all)

android:autoText 如果设置,将自动执行输入值的拼写纠正。此处无效果,在显示输入法并输入的时候起作用。

android:bufferType 指定getText()方式取得的文本类别。选项editable 类似于StringBuilder可追加字符,也就是说getText后可调用append方法设置文本内容。spannable 则可在给定的字符区域使用样式,参见这里1、这里2。

android:capitalize 设置英文字母大写类型。此处无效果,需要弹出输入法才能看得到,参见EditView此属性说明。

 android:cursorVisible 设定光标为显示/隐藏,默认显示。 android:digits  设置允许输入哪些字符。如“1234567890.+-*/%\n()” android:drawableBottom  在text的下方输出一个drawable,如图片。如果指定一个颜色的话会把text的背景设为该颜色,并且同时和background使用时覆盖后者。

android:drawableLeft 在text的左边输出一个drawable,如图片。

android:drawablePadding   设置text与drawable(图片)的间隔,与drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可设置为负数,单独使用没有效果。

android:drawableRight 在text的右边输出一个drawable,如图片。  android:drawableTop 在text的正上方输出一个drawable,如图片。

android:editable  设置是否可编辑。这里无效果,参见EditView。

android:editorExtras  设置文本的额外的输入数据。在EditView再讨论。

android:ellipsize  设置当文字过长时,该控件该如何显示。有如下值设置:”start”—–省略号显示在开头;”end”——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动)  android:freezesText 设置保存文本的内容以及光标的位置。参见:这里。

android:gravity  设置文本位置,如设置成“center”,文本将居中显示。

android:hint  Text为空时显示的文字提示信息,可通过textColorHint设置提示信息的颜色。比较奇怪的是TextView本来就相当于Label,怎么会不设置Text?! 

android:imeOptions  附加功能,设置右下角IME动作与编辑框相关的动作,如actionDone右下角将显示一个“完成”,而不设置默认是一个回车符号。这个在EditView中再详细说明,此处无用。

 android:imeActionId 设置IME动作ID。在EditView再做说明,可以先看这篇帖子:这里。  android:imeActionLabel 设置IME动作标签。在EditView再做说明。  android:includeFontPadding 设置文本是否包含顶部和底部额外空白,默认为true。  android:inputMethod  为文本指定输入法,需要完全限定名(完整的包名)。例如:com.google.android.inputmethod.pinyin,但是这里报错找不到。 

android:inputType 设置文本的类型,用于帮助输入法显示合适的键盘类型。在EditView中再详细说明,这里无效果。  android:linksClickable 设置链接是否点击连接,即使设置了autoLink。

android:marqueeRepeatLimit 在ellipsize指定marquee的情况下,设置重复滚动的次数,当设置为 marquee_forever时表示无限次。

android:ems  设置TextView的宽度为N个字符的宽度。这里测试为一个汉字字符宽度,如图:

android:maxEms  设置TextView的宽度为最长为N个字符的宽度。与ems同时使用时覆盖ems选项。

android:minEms  设置TextView的宽度为最短为N个字符的宽度。与ems同时使用时覆盖ems选项。 android:maxLength  限制显示的文本长度,超出部分不显示。

android:lines 设置文本的行数,设置两行就显示两行,即使第二行没有数据。

android:maxLines 设置文本的最大显示行数,与width或者layout_width结合使用,超出部分自动换行,超出行数将不显示。 

android:minLines 设置文本的最小行数,与lines类似。

android:lineSpacingExtra  设置行间距。 android:lineSpacingMultiplier 设置行间距的倍数。如”1.2”

android:numeric  如果被设置,该TextView有一个数字输入法。此处无用,设置后唯一效果是TextView有点击效果,此属性在EdtiView将详细说明。

android:password 以小点”.”显示文本

android:phoneNumber 设置为电话号码的输入方式。

android:privateImeOptions 设置输入法选项,此处无用,在EditText将进一步讨论。

android:scrollHorizontally 设置文本超出TextView的宽度的情况下,是否出现横拉条。

android:selectAllOnFocus  如果文本是可选择的,让他获取焦点而不是将光标移动为文本的开始位置或者末尾位置。TextView中设置后无效果。

android:shadowColor  指定文本阴影的颜色,需要与shadowRadius一起使用。效果: android:shadowDx 设置阴影横向坐标开始位置。 

android:shadowDy 设置阴影纵向坐标开始位置。

android:shadowRadius  设置阴影的半径。设置为0.1就变成字体的颜色了,一般设置为3.0的效果比较好。

android:singleLine  设置单行显示。如果和layout_width一起使用,当文本不能全部显示时,后面用“…”来表示。如android:text="test_ singleLine " android:singleLine="true" android:layout_width="20dp"将只显示“t…”。如果不设置singleLine或者设置为false,文本将自动换行  android:text 设置显示文本. android:textAppearance  设置文字外观。如“?android:attr/textAppearanceLargeInverse ”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse  android:textColor 设置文本颜色

android:textColorHighlight  被选中文字的底色,默认为蓝色 android:textColorHint 设置提示信息文字的颜色,默认为灰色。与hint一起使用。

android:textColorLink 文字链接的颜色. android:textScaleX  设置文字之间间隔,默认为1.0f。分别设置0.5f/1.0f/1.5f/2.0f效果如下:

android:textSize  设置文字大小,推荐度量单位”sp”,如”15sp” android:textStyle  设置字形[bold(粗体) 0, italic(斜体) 1, bolditalic(又粗又斜) 2] 可以设置一个或多个,用“|”隔开  android:typeface  设置文本字体,必须是以下常量值之一:normal 0, sans 1, serif 2, monospace(等宽字体) 3]  android:height 设置文本区域的高度,支持度量单位:px(像素)/dp/sp/in/mm(毫米)

android:maxHeight 设置文本区域的最大高度

android:minHeight 设置文本区域的最小高度

android:width 设置文本区域的宽度,支持度量单位:px(像素)/dp/sp/in/mm(毫米),与layout_width的区别看这里。 

android:maxWidth 设置文本区域的最大宽度 android:minWidth 设置文本区域的最小宽度

 


<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:id="@+id/security_settings_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
       
        <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="5sp"

        android:typeface="monospace"

        android:text="Hello Red Monospace"

        android:textSize="16sp"

        android:textColor="#ff0000"

        /> 

  

    <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="Sans Font:"

        android:textSize="16sp"

        android:paddingLeft="5sp"

        /> 

    <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="5sp"

        android:typeface="sans"

        android:text="Hello Blue Sans"

        android:textSize="16sp"

        android:textColor="#0000ff"

        /> 

  

    <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="Serif Font:"

        android:textSize="16sp"

        android:paddingLeft="5sp"

        /> 

    <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="5sp"

        android:paddingRight="2sp"

        android:typeface="serif"

        android:text="Hello Green Serif"

        android:textSize="16sp"

        android:textColor="#00ff00"

        />
       
         <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="5sp"

        android:paddingTop="15sp"

        android:typeface="normal"

        android:text="I'm normal font but I'm also bold and italic"

        android:textSize="16sp"

        android:textStyle="bold|italic"

        android:textColor="#ffffff"

        /> 
       
        <TextView

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingLeft="5sp"

        android:paddingTop="15sp"

        android:paddingBottom="15sp"

        android:typeface="normal"

        android:text="I'm normal (bold) font but I have a shadow"

        android:textSize="16sp"

        android:textStyle="bold"

        android:shadowColor ="#0f0f0f"

        android:shadowRadius="0.5"

        android:shadowDx="1.5"

        android:shadowDy="1.3"

        android:textColor="#ffffff"

        android:background="#0000ff"

        />

    </LinearLayout>
</ScrollView>

标签:显示,text,字体,设置,Android,文本,小结,android,TextView
From: https://blog.51cto.com/u_16160131/6473876

相关文章

  • Android SeekBar的使用
    AndroidSeekBar的使用  <?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="......
  • 【Android】ListView与Button的共存问题解决
    【Android】ListView与Button的共存问题解决这两天在捣鼓ListViewwidget,为了在ListView中加入Button这类的有“点击”事件的widget,请教了不少高手,感谢LandMark对我的认真讲解,下面把解决过程描述一下。 ListView和其它能触发点击事件的widget无法一起正常工作的......
  • [android]使用线控耳机来操控应用功能
    使用线控耳机来操控应用功能  实现原理:通过广播拦截来实现。 (一)定义1个广播拦截器,用来拦截线控耳机按键产生的广播事件。 importandroid.content.BroadcastReceiver;importandroid.content.Context;importandroid.content.Intent;importandroid.os.Bundle;importandro......
  • android调用系统发短信界面功能
    android调用系统发短信界面功能 Intentintent=newIntent(Intent.ACTION_SENDTO,Uri.parse("smsto:13xxxxxxx")); startActivity(intent); 需要的权限: <uses-permissionandroid:name="android.permission.SEND_SMS"></uses-permission>......
  • 巴塞尔级数的一个小结论
    巴塞尔级数的一个小结论已知\[\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{1}{1^2}+\frac{1}{2^2}+\cdots=\frac{\pi^2}{6}\]经过运算得\[\left(1-\frac{1}{2^2}\right)\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{1}{1^2}+\frac{1}{3^2}+\frac{1}{5^2}+\cdots\]继续这样进行下去......
  • Android中杀掉当前进程
    android.os.Process.killProcess(android.os.Process.myPid())killProcess方法用于杀掉一个进程,它接收一个进程ID参数,我们可以通过myPid()方法获取当前程序的进程id。需要注意的是,killProcess()方法只能用于杀掉当前程序的进程,不能杀掉其他程序。......
  • Android的服务Service
    Android学了太久了,都忘了。复习下四大组件之一的Service。介绍Android的Service是一种在后台执行长时间运行操作的组件,它可以在没有用户界面的情况下执行任务,并且可以与应用程序的其他组件进行通信。Service通常用于处理网络请求、音乐播放、数据同步等需要在后台持续运行的任务......
  • 路由协议EIGRP知识小结
    EIGRP(EnhancedInteriorGatewayRoutingProtocol)增强内部网关路由协议,EIGRP结合了链路状态和距离矢量型路由选择协议的Cisco专用协议,采用弥散修正算法(DUAL)来实现快速收敛,可以不发送定期的路由更新信息以减少带宽的占用,支持Appletalk、IP、IPX、Novell和NetWare等多种网络层协......
  • Android-RIL&IMS源码分析
    一、需求1、了解IMS相关知识体系2、RILD与RILJ、IMS回调消息的机制二、相关概念2.1IMS        IMS全称是IPMultimediaSubsystem,中文意义为IP多媒体子系统。IMS是一种基于IP基础结构,能够融合数据、话音和移动等网络技术的系统。        IP=基于IP的......
  • 小米MIX 2升级Lineage OS 20(Android 13)卡进度0%
    参考lineageoswiki安装时sideload会卡进度0%,电脑终端卡在serving'lineage-20.0-20230608-nightly-chiron-signed.zip'(~0%)手机端卡在Verifyingupdatepackage...wiki步骤基本步骤:#重启到fastbootadbrebootbootloader#连接设备fastbootdevices#刷recoveryf......