1. 写一个类继承TextView
代码如下 | 复制代码 |
packagecom.example.tt; importandroid.content.Context; importandroid.graphics.Rect; importandroid.util.AttributeSet; importandroid.widget.TextView; publicclassScrollingTextViewextendsTextView { publicScrollingTextView(Context context, AttributeSet attrs,intdefStyle) { super(context, attrs, defStyle); } publicScrollingTextView(Context context, AttributeSet attrs) { super(context, attrs); } publicScrollingTextView(Context context) { super(context); } @Override protectedvoidonFocusChanged(booleanfocused,intdirection, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override publicvoidonWindowFocusChanged(booleanfocused) { if(focused) super.onWindowFocusChanged(focused); } @Override publicbooleanisFocused() { returntrue; } } |
2. xml 中增加属性
代码如下 | 复制代码 |
android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="80dip" android:layout_marginBottom="25dip" android:textSize="25sp" android:singleLine="true" android:textColor="@android:color/black" android:ellipsize="marquee" android:focusable="true" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" android:scrollHorizontally="true" android:text="这才是真正的文字跑马灯效果,文字移动速度,文字移动方向,文字移动的样式,动画等等……" android:background="#2FFFFFFF"/> |
3. 在activity中声明
代码如下 | 复制代码 |
packagecom.example.tt; importandroid.os.Bundle; importandroid.app.Activity; importandroid.view.Menu; publicclassMainActivityextendsActivity { @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } |
凡尔赛法环免广告版 最新版v1.69.1
下载天煞异种 安卓版v1.0.21
下载十三月 (Undecember)最新官方中文版v3.26.0200
下载我不是废柴无限99999钻999999金币游戏 不减反增版v1.2.16
下载我的女友是声优免广告 安卓版v1
我的女友是声优免广告是一款非常好玩的模拟经营类手游,玩家在游
石器帝国去广告版 v8
石器帝国免广告版是游戏的破解版本,在该版本中为玩家去除了广告
校园恋爱模拟器真人版去广告版 v0.0.7
校园恋爱模拟器真人版免广告版是游戏的破解版本,在该版本中为玩
教练我要开球馆内置菜单修改器 安卓版v1.5.4
教练我要开球馆内购版是一款模拟经营类游戏,玩家们将在游戏中创
我的游轮无限砖石 安卓版v1.7.0
我的游轮无限金币钻石版是一款模拟经营类游戏,你将成为一艘游轮