Android 开发TextView跑马灯设置,及其失效解决方法
2023-07-09 本文已影响0人
hao_developer
<TextView
android:layout_width="match_content"
android:layout_height="wrap_content"
android:text="@string/my_location"
android:focusable="true" //控件是否能够获取焦点
android:focusableInTouchMode="true" //是否在触摸模式下获得焦点
android:scrollHorizontally="true"
android:singleLine="true" //单行显示
android:ellipsize="marquee" //跑马灯显示(动画横向移动)
android:marqueeRepeatLimit="marquee_forever" //永久滚动
/>
失效解决方法:
在代码中设置 setSelected(true)
//不设置,跑马灯不生效
mTvText.setSelected(true);
mTvText.setText("11111111111111111111111111111111111111");