TextView控件之跑马灯效果

本文详细介绍了Android中TextView控件的使用方法,包括如何设置可点击、获取焦点、文本溢出显示方式、内容对齐方式、循环滚动次数及单行显示等属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<pre name="code" class="html"><TextView
        android:id="@+id/mygonggao"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="5dp"
        android:background="#FF5511"
        android:clickable="true"
        android:ellipsize="marquee"
        android:focusable="true"
        android:gravity="center"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="今日公告:今天晚上图书馆一楼科研报告厅举行互联网+学术报告会" >
    </TextView>
<pre name="code" class="html">clickable true 可被点击
<pre name="code" class="html">focusable <span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20px;">就是移动光标是这个控件是否会变成选中状态 true 会  false 不会</span>
<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20px;"><strong><span style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;">android:ellipsize=”start”—–省略号显示在开头 "...pedia"</span><br style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;" /><span style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;">android:ellipsize=”end”——省略号显示在结尾  "encyc..."</span><br style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;" /><span style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;">android:ellipsize=”middle”—-省略号显示在中间 "en...dia"</span><br style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;" /><span style="color: rgb(255, 0, 0); font-family: Arial; font-size: 14px; line-height: 26px;">android:ellipsize=”marquee”–以横向滚动方式显示(需获得当前焦点时)</span></strong></span>
<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20px;"></span><pre name="code" class="html"><span style="font-family: Arial; font-size: 14px; line-height: 26px;">gravity 是 控件中显示的内容   </span>
marqueeRepeatLimit 设置滚动循环的次数
<span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"></span><pre name="code" class="html">scrollHorizontally="true" <span style="font-family: Arial;">满了后是自动横着移动不是默认的换行</span><pre name="code" class="html">singleLine="true" 设置单行













                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值