设为首页 加入收藏

TOP

Android 使用TextView实现跑马灯效果(二)
2019-09-01 23:25:47 】 浏览:54
Tags:Android 使用 TextView 实现 马灯 效果
as.android.com/tools"
3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:paddingBottom="@dimen/activity_vertical_margin" 6 android:paddingLeft="@dimen/activity_horizontal_margin" 7 android:paddingRight="@dimen/activity_horizontal_margin" 8 android:paddingTop="@dimen/activity_vertical_margin" 9 tools:context=".MainActivity" > 10 11 <com.example.marqueetextview.MarqueeText 12 android:id="@+id/textview1" 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content" 15 android:ellipsize="marquee" 16 android:focusable="true" 17 android:focusableInTouchMode="true" 18 android:singleLine="true" 19 android:text="@string/hello_world" /> 20 21 <com.example.marqueetextview.MarqueeText 22 android:layout_width="wrap_content" 23 android:layout_height="wrap_content" 24 android:layout_below="@id/textview1" 25 android:layout_marginTop="20dp" 26 android:ellipsize="marquee" 27 android:focusable="true" 28 android:focusableInTouchMode="true" 29 android:singleLine="true" 30 android:text="@string/hello_world" /> 31 32 </RelativeLayout>

然后我们再看一下效果。

已经全部实现成功了。

那这到底是为什么呢? 奥秘就在我们重载的isFocused()这个函数. return true全部强制Focused.都有焦点了,就都能实现了

如果没设置,焦点都第一个,第二个就无法实现。

这个是我写的Demo:https://pan.baidu.com/s/1M1TghCh_R3kFnReM4li1VQ

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇环境状态界面 下一篇Android-蓝牙的网络共享与连接分析

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目