• 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>

  • 相关阅读:
    添加删除虚拟ip
    linux配置ant
    java类加载器
    java类的加载过程
    java反射机制
    spring原理
    spring-1
    spring所需包下载
    eclipse安装spring插件
    ubuntu下zaibbix3.2报警搭建
  • 原文地址:https://www.cnblogs.com/daochong/p/4888473.html
Copyright © 2020-2023  润新知