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.app6.MainActivity" > <com.example.TextView_flow.marqueeText
android:id="@+id/textView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"/>
<!-- TextView可以用其子类来声明,子类的表现形式是包名+类名
设置4条语功能语句才能实现跑马灯的效果-->
<com.example.TextView_flow.marqueeText
android:layout_below="@id/textView_1"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"/> </RelativeLayout>

marqueeText.java

package com.example.TextView_flow;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView; public class marqueeText extends TextView{ public marqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
} public marqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
} public marqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
/*
* 复写这个方法是第一个文本框得到了可聚焦为true的方法,以跑马灯形式显示,而其他文本框得不到
*/
@Override
public boolean isFocused() {
return true;
}
}

源代码:

package com.example.TextView_flow;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Android_TextVIew_flow_ex1的更多相关文章

随机推荐

  1. 2015长春 HDU 5531 Rebuild

    题意:n个顶点组成的多边形能否形成正多边形? #include <cstdio> #include <cstring> #include <cmath> #incl ...

  2. MyEclipse整合Git

    1. 在OSC@China申请账号,建立项目 2. MyEclipse中选择导入项目-->Git-->Projects from Git 3. 填入Git的地址.User Name和Pas ...

  3. 10分钟制作自己的手机QQ

    1.注册个bmob.cn的账号:什么是bmob?bmob就是一个提供了基本后台服务器数据库操作的一个平台,你可以不用担心后台操作,使用起来很方便,降低了开发的门槛,提高了开发效率. 2.创建应用: 这 ...

  4. yum 安装 PHP,apache,nginx,mysql

    如果是Centos OS 64 位,首先更新 rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarc ...

  5. stm32 cortext-M3 类型对齐问题【worldsing笔记】

    经过细测,Cortex-M3的double类型必须4字节对齐访问,其他诸如float,int,short 可以非对齐访问.否则将会产生硬件异常!即访问double类型地址必须能被4整除,测试代码如下: ...

  6. 关于 android的 渲染器 Shader

    因为公司在 自定义的画图上面比较苛刻(各种要求= =),最后又是改来改去的.反正是 Shader起到很大作用,特此记录一下下.在achartengine的基础上没有能满足他们= = androd 提供 ...

  7. 消息队列数量统计(MSMQ,Performance Counter)

    微软消息队列服务MSMQ (Microsoft Message Queue),工作在在线或者离线场景,并提供异步编程功能.互联网和企业开发很多场景应用,例如电商的订单处理流程,这是因为客户端不需要等待 ...

  8. Egret的第一个2048游戏

    http://bbs.egret-labs.org/thread-242-1-1.html 对于AS3的开发者来说,可以直接过渡到的HTML5框架就是Egret了,基本上是了解了TypeSprite的 ...

  9. Delphi- 操作EXCEL

    因工作需要,需要到操作EXCEL,先了解一下怎么读取EXCEL这个,做了一个DEMO,备注在这里 一.读取EXCEL unit Unit1; interface uses Windows, Messa ...

  10. thinkPHP配置项

    'URL_PATHINFO_DEPR'=>'-',//修改URL的分隔符 'TMPL_L_DELIM'=>'<{', //修改左定界符 'TMPL_R_DELIM'=>'}&g ...