android简易跑马灯
重点:焦点的选择(返回true使得焦点不被选择)
MarqueeText.java
package com.example.demo02;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewDebug.ExportedProperty;
import android.widget.TextView;
public class MarqueeText extends TextView{
public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
@ExportedProperty(category = "focus")
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}
}
activity_main.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.demo02.MainActivity" >
<com.example.demo02.MarqueeText
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
<com.example.demo02.MarqueeText
android:layout_below="@+id/textview1"
android:layout_marginTop="10dp"
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
</RelativeLayout>
android简易跑马灯的更多相关文章
- 在android中用跑马灯的效果显示textview
大家好,在我们通常的android project中,通常需要用到textview这一个布局文件,并且对于这一个显示布局所需要的文本文字内容. 下面我们就来介绍一种方法来实现在android中用跑马灯 ...
- Android:TextView跑马灯-详解
Android:TextView跑马灯_详解 引言: TextView之所以需要跑马灯,是由于文字太长,或者是吸引眼球. 关键代码如下: android:singleLine="true&q ...
- Android文字跑马灯控件(文本自动滚动控件)
最近在开发一个应用,需要用到文本的跑马灯效果,图省事,在网上找,但老半天都找不到,后来自己写了一个,很简单,代码如下: import android.content.Context; import a ...
- android textview 跑马灯
<TextView android:layout_width="match_parent" android:layout_height="48dp" an ...
- Android 纵向跑马灯滚动效果
像淘宝和京东都会有跑马灯的效果,今天给大家贡献下以前项目的一个demo,各位看官,且看效果图. 我们先定义一个Bean文件,这个实体类文件主要包含标题,内容描述,以及还有跳转的链接. LampBean ...
- android实现跑马灯效果
第一步:新建一个新项目,MarqueeTextView 首先为了观察到跑马灯效果,将要显示的文字极可能 写长.在strings.xml目录里面将 <string name="hello ...
- android实现跑马灯效果(能够实现两个以上跑马灯)
本文用了继承自TextView的MarqueeTextView来实现跑马灯效果.原因是,跑马灯效果是须要TextView拥有焦点才会跑动的.而有时候TextView获得焦点会有点耗时,造成要等待一段时 ...
- Android Studio [跑马灯]
MainActivity package com.xdw.secondapp; import android.graphics.Paint; import android.support.v7.app ...
- Android单行跑马灯效果实现
参考网址:https://www.jianshu.com/p/e6c1b825d322 起初,使用了如下XML布局: <TextView android:id="@+id/tv_per ...
随机推荐
- Solution: The process cannot access the file [filename] because it is being used by another process.
http://www.brianstevenson.com/blog/solution-the-process-cannot-access-the-file-filename-because-it-i ...
- BigDecimal的3个toString方法
本文介绍BigDecimal的3个toString方法的区别. BigDecimal类有3个toString方法,分别是toEngineeringString.toPlainString和toStri ...
- JVM(十一),垃圾回收之老年代垃圾收集器
十一.垃圾回收之老年代垃圾收集器 1.Serial Old收集器(标记整理算法-单线程-Client模式下) 2.Paraller Old收集器(标记整理算法-多线程-) 3.CMS收集器(标记清除算 ...
- 互联网上最可怕的搜索引擎:shodan
互联网上最可怕的搜索引擎:shodan 介绍:http://tech.qq.com/a/20130410/000013.htm
- 数据结构实验之链表八:Farey序列(SDUT 3331)
#include <bits/stdc++.h> using namespace std; typedef struct node { int data2; int data1;//mu ...
- kubernetes 的数据的存储 存储卷
根据应用本身是否 需要持久存储数据,以及某一此请求和此前的请求是否有关联性,可以分为四类应用: 1.有状态要存储 2.有状态无持久存储 3.无状态无持久存储4.无状态有持久存储 在k8s上的数据持久性 ...
- 学习Javascript的编程风格
Javascript编程风格 Douglas Crockford是Javascript权威,Json格式就是他的发明. 去年11月他有一个演讲(Youtube),谈到了好的Javascript编程 ...
- codeforces#1183F. Topforces Strikes Back(数论)
题目链接: http://codeforces.com/contest/1183/problem/F 题意: 给出n个数,找出最多三个互不整除的数,取最大的和 数据范围: $1 \le n \le 2 ...
- Visual Studio Code(VS code)介绍
一.日常安利 VS code VS vode特点: 开源,免费: 自定义配置 集成git 智能提示强大 支持各种文件格式(html/jade/css/less/sass/xml) 调试功能强大 各种方 ...
- FileZilla 客户端连接vsftp无法访问 Received unexpected end-of-file from SFTP server 解决之路
首先在win通过ftp连接centos过程中,出现了2个问题,现在对此记录一下,方便后人遇到问题进行查阅 1.由于加密协议不同,需要在ftp客户端设置一下,支持ssh模式,具体自行百度: 2.在设置完 ...