android 文字太长跑马灯获不到焦点无法显示效果的一种解决方法
2015-05-07 12:00
639 查看
自定义一个类
public class MarqueeText extends TextView {
public MarqueeText(Context con) {
super(con);
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
@Override
protected void onFocusChanged(boolean focused, int direction,
Rect previouslyFocusedRect) {
}
}
在配置文件中加入
<com.example.MarqueeText
android:id="@+id/AMTV1"
android:layout_width="400dip"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:textSize="25sp"
android:textColor="@android:color/black"
android:lines="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:background="#2FFFFFFF"
android:text="这才是真正的文字跑马灯效果,文字移动速度,文字移动方向,文字移动的样式,动画等等……"
/>
public class MarqueeText extends TextView {
public MarqueeText(Context con) {
super(con);
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
@Override
protected void onFocusChanged(boolean focused, int direction,
Rect previouslyFocusedRect) {
}
}
在配置文件中加入
<com.example.MarqueeText
android:id="@+id/AMTV1"
android:layout_width="400dip"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:textSize="25sp"
android:textColor="@android:color/black"
android:lines="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:background="#2FFFFFFF"
android:text="这才是真正的文字跑马灯效果,文字移动速度,文字移动方向,文字移动的样式,动画等等……"
/>
相关文章推荐
- 一种解决无法显示Wikipedia图片的方法
- 关于图片资源在android2.1/2.2/2.3下无法显示的问题以及解决方法
- Android ListView 中子控件无法获取焦点的解决方法(主要针对键盘操作)
- android真机调试时无法显示logcat信息的解决方法介绍
- android fragment切换无法保存状态的一种解决方法
- android fragment切换无法保存状态的一种解决方法
- 关于使用NotificationComat导致android2.3及以下版本无法显示自定义布局的解决方法.
- [Android]浮层视频效果,在另外一个Window使用SurfaceView无法正常显示的问题排查与解决
- Eclipse下导出java程序可执行的jar包图片无法显示问题的一种解决方法
- Android 4.0+ EditText.setError("错误提示信息")不显示文字的解决方法
- Eclipse下导出java程序可执行的jar包图片无法显示问题的一种解决方法
- Visual Leak Detector无法显示Call Stack文字的解决方法
- TextView设置android:ellipsize="marquee"属性,无法实现跑马灯效果的解决方法
- Android listview 的 item 点击无效(无法获取焦点)的解决方法
- Android中Button文字不能一行显示解决方法
- Android Service中使用Toast无法正常显示问题的解决方法
- [置顶] Android MVVM DataBinding在Fragment onCreateView()中getAdapter()显示空指针的问题的一种解决方法
- ToolBar中menu无法同时显示图标和文字问题的解决方法
- Android开发 File Explorer无法显示目录的解决办法
- Android弹出dialog后无法捕捉back键的解决方法