textview滚动条效果的text

<TextView

android:id="@+id/item1_title_message"

android:layout_width="160dip"

android:layout_height="wrap_content"

android:layout_gravity="center_vertical"

android:layout_marginLeft="20dip"

//设置当文字过长时,该控件该如何显示。有如下值设置:”start”—?省略号显示在开头;”end” ——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动)       

android:ellipsize="marquee"

android:focusable="true"

android:focusableInTouchMode="true"

android:gravity="center_vertical"

android:marqueeRepeatLimit="marquee_forever"

android:singleLine="true"

android:text="好消息:今天是2015年的第一天,大碗干拌祝大家新年快乐"

/>
文字滚动效果会自动运行

如果需要点击滚动 需要处理焦点

<LinearLayout android:layout_width="fill_parent"  

        android:layout_height="100dip"  

        android:clickable="true"  

        android:focusable="true"  

        android:focusableInTouchMode="true"  

        />  

    <TextView  

        android:layout_width="100dip"  

        android:layout_height="wrap_content"  

        android:layout_gravity="center"  

        android:text="走马灯效果的演示"   

        android:singleLine="true"  

        android:ellipsize="marquee"  

        android:clickable="true"  

        android:focusable="true"  

        android:focusableInTouchMode="true"  

        ></TextView>  

 

</LinearLayout>  

这段代码运行之后,首先走马灯不出现,代码中的第二个LinearLayout获得焦点,然后我们点击第二个TextView,走马灯出现,然后我们点击TextView上方的区域,

 走马灯效果消失,说明焦点转移到代码中的第二个LinearLayout。

,在触摸模式下android:clickable="true"是(android:focusable="true",android:focusableInTouchMode="true")能获得焦点的必要条件,

就是说一个控件想要在触摸模式下获得焦点就一定要可点击,上面三个属性都要有。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值