首页 > 移动平台 > 详细

android 跑马灯

时间:2015-09-14 01:48:40      阅读:195      评论:0      收藏:0      [点我收藏+]

                         跑马灯效果

layout布局代码

<!--android:ellipsize 设置文字过长时,该控件是如何显示的呢?

start—省略号显示在开头 end—省略号显示在结尾 middle—省略号显示在中间

marquee—以跑马灯的方式显示 -->

<!--无数次的跑动-->

android:marqueeRepeatLimit=”marquee_forever”

<!--触摸时获得焦点-->

android:focuseableTouchMode=”true”

<!--使文本单行显示-->

android:singleLine="true"

<!--以包名调用MyTextView中的方法 -->

<!--android:layout_below="@+id/textview"把该组件的底部置于给定ID的组件之下(PS:把当前组件放在给定ID组件的下面) -->

<!--android:layout_above="@+id/textview"把该组件的底部置于给定ID的组件之上(PS:把当前组件放在给定ID组件的上面) -->

<

cn.androidstudy.pmd.MyTextView

android:id="@+id/textview"        

android:layout_width="wrap_content"        

android:layout_height="wrap_content"        

android:singleLine="true"        

android:ellipsize="marquee"        

android:focusableInTouchMode="true"        

android:focusable="true"        

android:text="@string/hello_world" />         

<cn.androidstudy.pmd.MyTextView

android:id="@+id/textview1"        

android:layout_width="wrap_content"        

android:layout_height="wrap_content"        

android:singleLine="true"        

android:ellipsize="marquee"        

android:focusableInTouchMode="true"        

android:focusable="true"        

android:layout_below="@+id/textview"        

android:text="@string/hello_world" />           

<cn.androidstudy.pmd.MyTextView        

android:id="@+id/textview2"        

android:layout_width="wrap_content"        

android:layout_height="wrap_content"        

android:singleLine="true"        

android:ellipsize="marquee"        

android:focusableInTouchMode="true"        

android:focusable="true"        

android:layout_below="@+id/textview1"        

android:text="@string/hello_world" />

多个跑马灯的class文件

package cn.androidstudy.pmd;

import android.content.Context;

import android.util.AttributeSet;

import android.widget.TextView;

public class MyTextView extends TextView{

 public MyTextView(Context context) {   

super(context);   // TODO Auto-generated constructor stub  }

 public MyTextView(Context context, AttributeSet attrs, int defStyle) {

  super(context, attrs, defStyle);   // TODO Auto-generated constructor stub  }

 public MyTextView(Context context, AttributeSet attrs) {   

super(context, attrs);   // TODO Auto-generated constructor stub  }

 public boolean isFocused(){   

return true;  }   }

android 跑马灯

原文:http://www.cnblogs.com/yckv/p/4805981.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!