重点:焦点的选择(返回true使得焦点不被选择)

MarqueeText.java

package com.example.demo02;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewDebug.ExportedProperty;
import android.widget.TextView;

public class MarqueeText extends TextView{

public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// TODO Auto-generated constructor stub
}

public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

@Override
@ExportedProperty(category = "focus")
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}

}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.demo02.MainActivity" >

<com.example.demo02.MarqueeText
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />

<com.example.demo02.MarqueeText
android:layout_below="@+id/textview1"
android:layout_marginTop="10dp"
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />

</RelativeLayout>

android简易跑马灯的更多相关文章

  1. 在android中用跑马灯的效果显示textview

    大家好,在我们通常的android project中,通常需要用到textview这一个布局文件,并且对于这一个显示布局所需要的文本文字内容. 下面我们就来介绍一种方法来实现在android中用跑马灯 ...

  2. Android:TextView跑马灯-详解

    Android:TextView跑马灯_详解 引言: TextView之所以需要跑马灯,是由于文字太长,或者是吸引眼球. 关键代码如下: android:singleLine="true&q ...

  3. Android文字跑马灯控件(文本自动滚动控件)

    最近在开发一个应用,需要用到文本的跑马灯效果,图省事,在网上找,但老半天都找不到,后来自己写了一个,很简单,代码如下: import android.content.Context; import a ...

  4. android textview 跑马灯

    <TextView android:layout_width="match_parent" android:layout_height="48dp" an ...

  5. Android 纵向跑马灯滚动效果

    像淘宝和京东都会有跑马灯的效果,今天给大家贡献下以前项目的一个demo,各位看官,且看效果图. 我们先定义一个Bean文件,这个实体类文件主要包含标题,内容描述,以及还有跳转的链接. LampBean ...

  6. android实现跑马灯效果

    第一步:新建一个新项目,MarqueeTextView 首先为了观察到跑马灯效果,将要显示的文字极可能 写长.在strings.xml目录里面将 <string name="hello ...

  7. android实现跑马灯效果(能够实现两个以上跑马灯)

    本文用了继承自TextView的MarqueeTextView来实现跑马灯效果.原因是,跑马灯效果是须要TextView拥有焦点才会跑动的.而有时候TextView获得焦点会有点耗时,造成要等待一段时 ...

  8. Android Studio [跑马灯]

    MainActivity package com.xdw.secondapp; import android.graphics.Paint; import android.support.v7.app ...

  9. Android单行跑马灯效果实现

    参考网址:https://www.jianshu.com/p/e6c1b825d322 起初,使用了如下XML布局: <TextView android:id="@+id/tv_per ...

随机推荐

  1. No module named 'pip._vendor.progress.helpers' 的解决方法

    莫名其妙的pip出现故障了 ModuleNotFoundError: No module named ‘pip._vendor.progress.helpers’ 在百度搜索了一圈也没看到这个错误的解 ...

  2. 适配器模式(Adapter)---结构型

    1 基础知识 定义:将一个类的接口(被适配者)转换成客户期望的另一个接口(目标).特征:使原本接口不兼容的类可以一起工作. 本质:转换匹配,复用功能.把不兼容的接口转换为客户端期望的样子从而实现功能的 ...

  3. @WebServlet @WebListener @WebListener

  4. Http通讯协议

    第一.http 通信协议的基本原理 一次 HTTP 请求的通信流程 流程图     DNS: (Domain Name System)服务是和 HTTP 协议一样位于应用层的协议.它提供域名到 IP ...

  5. CodeForces 535C Tavas and Karafs —— 二分

    题意:给出一个无限长度的等差数列(递增),每次可以让从l开始的m个减少1,如果某个位置已经是0了,那么可以顺延到下一位减少1,这样的操作最多t次,问t次操作以后从l开始的最长0序列的最大右边界r是多少 ...

  6. python关闭socket端口立即释放

    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.setsockopt(socket.SOL_SOCKET, sock ...

  7. spring boot打包以及centos下部署

    spring boot打包以及部署 一.打包 springboot的打包方式有很多种.有打成war的,有打成jar的,也有直接提交到github,通过jekins进行打包部署的.这里主要介绍如何打成j ...

  8. postgresql数据库的 to_date 和 to_timestamp 将 字符串转换为时间格式

    数据库中:字符串 转换为 时间格式 二者区别: to_data 转换为 普通的时间格式        to_timestamp 转换可为 时间戳格式出错场景: 比较同一天 日期大小的时候,很容易出错 ...

  9. redis 用scan 代替keys,hgetAll

    转载自:https://blog.csdn.net/w05980598/article/details/80264568 众所周知,当redis中key数量越大,keys 命令执行越慢,而且最重要的会 ...

  10. POJ 2488 -- A Knight's Journey(骑士游历)

    POJ 2488 -- A Knight's Journey(骑士游历) 题意: 给出一个国际棋盘的大小,判断马能否不重复的走过所有格,并记录下其中按字典序排列的第一种路径. 经典的“骑士游历”问题 ...