当我使用Digital clock和textview marquee时,textview marquee就不能工作--如果我移除数字时钟,它就会完美地工作。
TextView tv = new TextView(this);
tv.setLayoutParams(paramsSong);
tv.setEllipsize(TruncateAt.MARQUEE);
tv.setFocusableInTouchMode(true);
tv.setFreezesText(true);
tv.setSingleLine(true);
tv.setMarqueeRepeatLimit(-1);
tv.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
tv.setSelected(true);
rl.addView(tv);
DigitalClock dg = new DigitalClock(this);
rl.addView(dg);
/*if I remove digital clock then it works*/我能不能同时使用这两种方法,或者有什么解决办法?
发布于 2013-08-26 09:59:02
是的,你可以用这些,但首先要改正你的错误
1.您要添加rl.addView(tv); 2次视图
2. set Height和Width of DigitalClock
试试下面的代码,这些代码对我很好
TextView tv = new TextView(this);
rl.addView(tv);// Here is Your Mistake ! Remove it
tv.setLayoutParams(paramsSong);
tv.setEllipsize(TruncateAt.MARQUEE);
tv.setFocusableInTouchMode(true);
tv.setFreezesText(true);
tv.setSingleLine(true);
tv.setMarqueeRepeatLimit(-1);
tv.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
tv.setSelected(true);
rl.addView(tv);// Adding view Here is Absolutely Right !
DigitalClock dg = new DigitalClock(this);
dg.setHeight(setHeightHere);
dg.setWidth(setWidthHere);
rl.addView(dg);PS. DigitalClock class was deprecated in API level 17
Docs http://developer.android.com/reference/android/widget/DigitalClock.html
This class was deprecated in API level 17.
It is recommended you use TextClock instead.http://developer.android.com/reference/android/widget/TextClock.html
https://stackoverflow.com/questions/18441311
复制相似问题