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. sql 统计用的sql

    mh:工时   mhtype:工时类型(6种) 字段:userid      mhtype    mh       001          1        5       001          ...

  2. [RQNOJ313]波浪数

    题目描述 波浪数是在一对数字之间交替转换的数,如1212121,双重波浪数则是指在两种进制下都是波浪数的数,如十进制数191919是一个十进制下的波浪数,它对应的十一进制数121212也是一个波浪数, ...

  3. 命令mv

    mv 文件 目标目录如果目标目录改成文件名,mv命令可用于重命名文件.

  4. [转载] Zookeeper中的 ACL(Access Control List)访问控制列表

    zk做为分布式架构中的重要中间件,通常会在上面以节点的方式存储一些关键信息,默认情况下,所有应用都可以读写任何节点,在复杂的应用中,这不太安全,ZK通过ACL机制来解决访问权限问题,详见官网文档:ht ...

  5. hdu4812-D Tree (树的点分治)

    昨天学了下树分治,今天补这道题,还是太不熟练了,写完之后一直超时.后来查出好多错= =比如v,u写倒了,比如+写成了取最值,比如....爆int...查了两个多小时的错..哭...(没想到进首页了 h ...

  6. [POLITICS] S Korea lawmakers vote to impeach leader

    South Korea's Parliament has voted to impeach President Park Geun-hye. The National Assembly motion ...

  7. Arrays 类操作 Java 的数组排序

    使用 Arrays 类操作 Java 中的数组 Arrays 类是 Java 中提供的一个工具类,在 java.util 包中.该类中包含了一些方法用来直接操作数组,比如可直接实现数组的排序.搜索等( ...

  8. svn 如何解决冲突

    项目中,往往不止你一人开发,多人开发,难免会有代码的冲突.彼此间谁也不能保证不会修改同个文件.如果修改了同个方法的内容.这时提交到svn是会提示代码冲突的. 当然,冲突是可控的,但不能避免.每次写代码 ...

  9. java正则表达式入门基础

    一.正则表达式术语 1)元字符 : 非一般字符,具有某种意义的字符.如 : \bX : \b边界符, 以 X开始的单词 2) 常用 : \d : 匹配一个数字 : \d ,  匹配至少一个以上数字 \ ...

  10. 通过Wifi调试Android应用

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...