zoukankan      html  css  js  c++  java
  • Android学习(二) 标签滚动跳过

    <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=".MainActivity" >
    
        <com.example.marqueetextview.MarqueeText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:text="@string/hello_world" />
        
        <com.example.marqueetextview.MarqueeText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:text="@string/hello_world" />
    
    </RelativeLayout>

    后台实现:

    public class MarqueeText extends TextView{
    
        public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
            // 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() {
            //继承TextView类,重写isFocused方法,返回true,因为marquee只有在当前控件获取焦点时才会滚动。
            return true;
        }
    
    }
  • 相关阅读:
    hdu 1254 推箱子(双重bfs)
    hdu 1495 非常可乐 (广搜)
    [leetcode-687-Longest Univalue Path]
    [leetcode-686-Repeated String Match]
    POJ 2287 田忌赛马 贪心算法
    [leetcode-304-Range Sum Query 2D
    [leetcode-682-Baseball Game]
    [leetcode-299-Bulls and Cows]
    [leetcode-319-Bulb Switcher]
    [leetcode-680-Valid Palindrome II]
  • 原文地址:https://www.cnblogs.com/zhengcheng/p/4351238.html
Copyright © 2011-2022 走看看