Text组件是最基本的组件,后面还会学习他的子类组件,比如Button,TextField都是从这个类衍生而来的。
常见的属性:
这些属性不用去背,用着用着就熟了,想要对文本进行一个设置,如果忘记属性,可以直接到笔记中找,或者到华为开发者文档中找。
常用属性
功能说明 | 属性名称 |
---|---|
id属性,唯一 | id |
组件宽 | width |
组件高 | height |
文本内容 | text |
背景,可以设颜色值或xml背景 | background_element |
文字颜色 | text_color |
文字粗细 | text_weight |
斜体 | italic |
文字尺寸单位: fp | text_size |
字体。如: 黑体、宋体、楷体 | text_font |
文字内容对齐方式 | text_alignment |
左/右外间距 | left_margin / right_margin |
上下外间距 | top_magin / bottom_margin |
左/右内间距 | left_padding / right_padding |