常用控件----TextView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
  >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/textColor"
        android:textSize="26sp"
        android:text="Hello World!"
        android:gravity="center"
        />

</LinearLayout>

定义的唯一标识符

android:id="@+id/textView3  

指定控件的宽度和高度,在android中所有的的控件都有这两个属性。选值有三种:match_parent,wrap_content,fill_parent。match_parent和fill_parent意义相同。

  • match_parent:让当前控件的大小和父布局的大小一样。由父布局来决定当前控件的大小
  • wrap_content:让当前控件的大小能够刚好包含住里面的内容,也就是由控件内容决定当前控件的大小。
android:layout_width="match_parent
android:layout_height="wrap_content

在TextView中文字默认居左上角对齐的,有时文字内容不够长,并没有覆盖整个屏幕宽度通过修改android:gravity来调整对齐方式.可选值有top,bottom,left,right,center。可以用 | 来同时指定多个值。center效果等同于center_vertical | center_horizontal,表示文字在垂直和水平方向都居中对齐

android:gravity="center"

文字大小和颜色,通过android:textSize属性指定文字大小,通过android:textColor属性指定文字颜色,在Android中字体大小使用sp作为单位。

android:textColor="@color/textColor"
android:textSize="26sp"

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值