android textview怎么实现当字符串宽度没超过控件宽度时,靠右对齐,控件宽度不足以显示所有字符串时,字符串靠左对齐,同时实现跑马灯效果。 android, TextviewandroidTextview跑马灯效果动态左或右对齐 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /** * 文字自动移动的TextView */public class MarqueeTextView extends TextView{ public MarqueeTextView(Context context) { super(context); init(); } public MarqueeTextView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { setEllipsize(TextUtils.TruncateAt.MARQUEE); setMarqueeRepeatLimit(Integer.MAX_VALUE); } @Override public boolean isFocused() { return true; }}XML: <com.xx.widget.MarqueeTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true"/> 这样只是可以实现跑马灯效果,我自己可以实现跑马灯效果,现在困难是Textview可以完全显示字符串的时候我要setGravity(Gravity.Right)靠右显示,但是字符串长过TextView控件宽度的时候要从字符串的第0个开始显示,然后现在是显示字符串的后面的字符,前面的字符被盖住了,虽然有跑马灯效果,但是刚显示的时候前面的字符显示不出来。 谁推荐一款39寸-42寸的电视机,想玩玩安卓开发!国产的也无所谓,越便宜越好。 android开发分工 求微信实现思路。。。 C#和android两个程序中如何生成同一个随机数序列? 【急】Android画图,旋转问题请教!!!! android 开发用什么手机好 晒晒你们的手机 android 创建控件create和findViewById的区别 Android通信问题 图片预览问题 4.0以上如何从WebView的缓存中获取已缓存的图片 这种布局怎么弄 Android Web开发实现教务系统登陆。
* 文字自动移动的TextView
*/
public class MarqueeTextView extends TextView
{
public MarqueeTextView(Context context)
{
super(context);
init();
} public MarqueeTextView(Context context, AttributeSet attrs)
{
super(context, attrs);
init();
} public MarqueeTextView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
init();
} private void init()
{
setEllipsize(TextUtils.TruncateAt.MARQUEE);
setMarqueeRepeatLimit(Integer.MAX_VALUE);
} @Override
public boolean isFocused()
{
return true;
}
}
XML:
<com.xx.widget.MarqueeTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"/>
现在困难是Textview可以完全显示字符串的时候我要setGravity(Gravity.Right)靠右显示,但是字符串长过TextView控件宽度的时候要从字符串的第0个开始显示,然后现在是显示字符串的后面的字符,前面的字符被盖住了,虽然有跑马灯效果,但是刚显示的时候前面的字符显示不出来。