跑马灯
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingTop="90dp" android:paddingLeft="16dp" android:paddingRight="16dp" tools:context="com.dream.dream.MainActivity" tools:showIn="@layout/activity_main"> <com.dream.dream.Marquee android:focusableInTouchMode="true" android:focusable="true" android:singleLine="true" android:ellipsize="marquee" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text_view" /> <com.dream.dream.Marquee android:focusableInTouchMode="true" android:focusable="true" android:singleLine="true" android:ellipsize="marquee" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text_view2" /> </LinearLayout>
package com.dream.dream; import android.content.Context; import android.util.AttributeSet; import android.widget.TextView; /** * Created by dream on 2016/1/22. */ public class Marquee extends TextView { public Marquee(Context context) { super(context); } public Marquee(Context context, AttributeSet attrs) { super(context, attrs); } public Marquee(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public boolean isFocused() { return true; } }