Android 开发、布局管理器、TextView、Android跑马灯

目录

布局管理器

线性布局

相对布局

TextView

文段、文本

文字+icon

中划线、下划线

跑马灯


布局管理器

线性布局

LinearLayout常用属性

  • android:id

  • android:layout_width

  • android:layout_height

  • android:background 背景

  • android:layout_margin 外边距 top顶部

  • android:layout_padding 内边距

  • android:orientation 方向 vertica垂直排列 horizontal水平排列

  • android:layout_weight 剩余比重

相对布局

RelativeLayout常用属性

  • android:layout_toLeftOf 在谁的左边

  • android:layout_toRightOf 在谁的右边

  • android:layout_alignBottom 跟谁底部对齐

  • android:layout_alignParentBottom 跟父空间底部对齐

  • android:layout_below 在谁的下部

TextView

文字大小、颜色

  • textSize 字体大小

  • textColor 字体颜色

文段、文本

  • maxLines 行数限制

  • ellipsize=“end” 多出位置…

文字+icon

  • drawableRight 右侧插入图片

中划线、下划线

        private TextView mTv3,mTv4,mTv5;
//下面在方法中添加
        mTv3 = findViewById(R.id.tv_3);
        mTv3.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
        mTv3.getPaint().setAntiAlias(true);//去锯齿

        mTv4 = findViewById(R.id.tv_4);
        mTv4.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线

        mTv5 = findViewById(R.id.tv_5);
        mTv5.setText(Html.fromHtml("<u>你好,AndroidStudio"));//HTML实现下划线

跑马灯

  • singleLine="true" 单行显示

  • ellipsize="marquee" 跑马灯

  • marqueeRepeatLimit="marquee_forever" 循环次数

  • focusable="true" 获得焦点

  • focusableInTouchMode="true"

<TextView
        android:id="@+id/tv_6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Android 跑马灯 Android 跑马灯 Android 跑马灯 Android 跑马灯 Android 跑马灯 Android 跑马灯"
        android:textColor="#f10317"
        android:textSize="24sp"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:focusable="true"
        android:focusableInTouchMode="true"/>

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IM汤姆凯特

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值