Android_TextVIew_flow_ex1
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的更多相关文章
随机推荐
- 《深入Java虚拟机学习笔记》- 第17章 异常
<深入Java虚拟机学习笔记>- 第17章 异常
- SQL游标
最近工作中有用到游标,特简单总结一下: 一.简介 游标(Cursor)是处理数据的一种方法,为了查看或者处理结果集中的数据,游标提供了在结果集中一次以行或者多行前进或向后浏览数据的能力.我们 ...
- iOS开发UI篇—实现一个私人通讯录小应用【转】
转一篇学习segue不错的教程 一.该部分主要完成内容 1.界面搭建 2.功能说明 (1).只有当账号和密码输入框都有值的时候,登录按钮才能交互 (2). ...
- 线性表-串:KMP模式匹配算法
一.简单模式匹配算法(略,逐字符比较即可) 二.KMP模式匹配算法 next数组:j为字符序号,从1开始. (1)当j=1时,next=0: (2)当存在前缀=后缀情况,next=相同字符数+1: ( ...
- Her and his blog
Tonight, I read localhost8080 and some of her husband m67's blog. I found they are so geek and reall ...
- java创建对象的四种方式
1.最常见的 new 一个 2使用反射机制创建对象,直接调用非构造函数 Class obj=Class.forName("A"); A a=obj.newInstance(); C ...
- 【原创】tcp协议那块一些点(想到了再加)
1.3次握手 4次握手 2.那张状态图,FIN_WAIT主动关闭方,CLOSE_WAIT被动关闭方 主动关闭方发出FIN后进入FIN_WAIT,FIN_WAIT方收到了ACK和FIN,发出了ACK,则 ...
- linux tar打包
范例一:将整个 /etc 目录下的文件全部打包成为 /tmp/etc.tar[root@linux ~]# tar -cvf /tmp/etc.tar /etc <==仅打包,不压缩![root ...
- UITextView详解
self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease]; //初始化大小并自动释放 sel ...
- openstack系列阅读目录
一 keystone系列 keystone基础 网关协议cgi,fastcgi,wsgi,uwsgi keystone源码分析 keystone部署及使用 keystone客户端工作介绍 二 glan ...