zoukankan      html  css  js  c++  java
  • android 跑马灯

                             跑马灯效果

    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;  }   }

    既然走上了这条路,那么久不能背信弃义,就要一直走下去。即使前面是刀山火海也要闯一闯。至于结果是悲喜,或许只有时间才能给出答案。
  • 相关阅读:
    Kubernetes学习之路(十)之资源清单定义
    Kubernetes学习之路(十一)之Pod状态和生命周期管理
    Kubernetes学习之路(七)之Coredns和Dashboard二进制部署
    Kubernetes学习之路(九)之kubernetes命令式快速创建应用
    Kubernetes学习之路(八)之Kubeadm部署集群
    Ceph学习之路(三)Ceph luminous版本部署
    Kubernetes学习之路(六)之创建K8S应用
    Redis学习之路(二)之Redis入门基础
    Redis学习之路(一)之缓存知识体系
    OpenStack入门篇(二十二)之实现阿里云VPC的SDN网络
  • 原文地址:https://www.cnblogs.com/yckv/p/4805981.html
Copyright © 2011-2022 走看看