1. 继承TextView自定义控件

package com.anjoyo.musicplayer.define;  import android.content.Context;  import android.graphics.Rect;  import android.util.AttributeSet;  import android.widget.TextView;    public class MarqueeTextView extends TextView {        public MarqueeTextView(Context context) {          super(context);  //      android:ellipsize="marquee"   //      android:focusable="true"   //      android:marqueeRepeatLimit="marquee_forever"   //      android:focusableInTouchMode="true"   //      android:scrollHorizontally="true"  ////      android:singleLine="true"  //      setSingleLine(true);  //      setEllipsize(TruncateAt.MARQUEE);  //      setFocusable(true);  //      setMarqueeRepeatLimit(Integer.MAX_VALUE);  //      setFocusableInTouchMode(true);      }            public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {          super(context, attrs, defStyle);          // TODO Auto-generated constructor stub      }        public MarqueeTextView(Context context, AttributeSet attrs) {          super(context, attrs);          // TODO Auto-generated constructor stub      }        @Override      protected void onFocusChanged(boolean focused, int direction,              Rect previouslyFocusedRect) {          if (focused) {              super.onFocusChanged(focused, direction, previouslyFocusedRect);          }      }        @Override      public void onWindowFocusChanged(boolean hasWindowFocus) {          if (hasWindowFocus) {              super.onWindowFocusChanged(hasWindowFocus);          }      }            @Override      public boolean isFocused() {          return true;      }        }  

2. 在布局中的使用

 

3. style.xml

  

更多相关文章

  1. android-仿iOS弹出框
  2. android中的有道词典
  3. Android(安卓)RecyclerView网格布局
  4. 自定义Dialog2
  5. Android(安卓)BaseFragment基类
  6. Android(安卓)Service系列(十)直接继承Service
  7. ANDROID -- Bluetooth
  8. Kotlin简单开发-RecyclerView
  9. Android(安卓)录制音频示例

随机推荐

  1. 【函数】wm_concat包的订制
  2. vue之elementui,树形组件el-tree实现左右
  3. 消除11.2上的db file parallel read
  4. 【等待事件】日志类 等待事件(4.1)--log fi
  5. 【BBED】bbed常用命令
  6. 【MOS:1549181.1】为何在查询中索引未被使
  7. 关于dual表的破坏性测试
  8. 【ASM】ASMCMD 磁盘元数据的备份与恢复实
  9. DUAL系列
  10. RAC 增加SCAN IP