2023年2月22日(软件工程日报)

今天完成其他必修课作业,外出闲逛,安卓学习较少

文本的显示

本节是学习文本控件,用text属性给文本进行相应的赋值需求,设置文本的内容

用String.xml表示

设置文本的大小用textSize表示,控件单位Android推荐dp,文字单位推荐sp,

在java文件中设置文本大小内容需要

view1 = findViewById(R.id.tv01;

view1.setText("你好,世界");

tvl.setText(R.string.joker);

view1.setTextSize(30);

<TextView

 android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="HelloWorld"

android:textSize="24sp"/>

设置文本颜色

xml中设置颜色与文字颜色和背景颜色相同

在java中

tvl.setTextColor(Color.BLACK);

tvl.setTextColor(0xff114514);

 

posted @ 2023-02-22 21:10  摆烂达人  阅读(20)  评论(0)    收藏  举报