TextView,Button等字体的循环滚动
来源:互联网 发布:剑元上至 知乎 编辑:程序博客网 时间:2024/05/16 10:00
跑马灯效果最重要的就是四个属性,分别是:
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
控件的宽度,不一定是具体的值,可以是math_parent,如果想让textview中的文字滚动的话,那里面内容的长度肯定是要大于控件的长度的,不然滚动还有啥意思..
不过这样写的话,虽然很简单.但是有一个问题.就是只有在控件获得到焦点的时候才可以滚动.如果我们在textview控件的下方,添加一个edittext,直接就回看到用这四个属性修饰的.刚刚那个还可以滚动的textview现在竟然一动不动了.这个时候我们就要来对textview进行自定义了
- package com.example.testscrotextview;
- import android.content.Context;
- import android.graphics.Rect;
- import android.util.AttributeSet;
- import android.widget.TextView;
- public class MyScrollTextView extends TextView {
- public MyScrollTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- public MyScrollTextView(Context context) {
- super(context);
- }
- @Override
- public boolean isFocused() {
- return true;//直接让他一直是获得焦点状态
- }
- @Override
- public void onWindowFocusChanged(boolean hasWindowFocus) {
- if(hasWindowFocus)//获得焦点的时候,才执行一些操作
- super.onWindowFocusChanged(hasWindowFocus);
- }
- @Override
- protected void onFocusChanged(boolean focused, int direction,
- Rect previouslyFocusedRect) {
- if(focused)//获得焦点的时候,才执行一些操作
- super.onFocusChanged(focused, direction, previouslyFocusedRect);
- }
- }
0 0
- TextView,Button等字体的循环滚动
- android给Button或TextView等设置字体
- TEXTVIEW 字体水平滚动
- TextView实现字体滚动
- TextView字体滚动效果
- Textview字体滚动
- 自动循环滚动textview
- Button,TextView点击字体变色
- TextView,Button实现滚动字幕
- 字体循环滚动
- Android 通过按钮Button更改全部的TextView、EditText、Button的字体大小、字体颜色、背景颜色
- Android 通过按钮Button更改全部的TextView、EditText、Button的字体大小、字体颜色、背景颜色
- 安卓实现走马灯效果 textview 实现字体循环滚动效果
- android如何写一个循环文字滚动的TextView
- android组件TextView实现字体水平滚动
- Android组件TextView实现字体水平滚动
- 给imageview,textview,button等添加边框
- TextView,Button 等设置 setCompoundDrawables 无效
- SSH连接linux时,长时间不操作就断开的解决方案
- strchr, strrchr函数实现——string.h库函数
- ZZULIOJ 1800 少水群多刷题
- 天声人語 20151208 真珠湾と日系移民
- [ahk]如何避免输入法的影响发送字母数字
- TextView,Button等字体的循环滚动
- Java处理数学公式得出结果
- C语言 变量的存储方式和生命周期
- Android_JSON数据解析
- C语言经典编程题--哥德巴赫猜想 、完数 、猜数字等
- 运行测试用例集过程中在jenkins控制台打印当前用例测试结果(testng)
- JS实现双击内容变为可编辑状态
- Android Adapter记住CheckBox状态
- Blowfish加密算法