zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    用户描述
    课堂练习
    一阶段11.21
    一阶段11.20
    一阶段 11.19
    自己动手写spring(五) bean的生命周期管理
    自己动手写spring(四) 整合xml与注解方式
    自己动手写spring(三) 支持注解方式
    自己动手写spring(二) 创建一个bean工厂
    自己动手写spring(一) 使用digester
  • 原文地址:https://www.cnblogs.com/daochong/p/4888473.html
Copyright © 2011-2022 走看看