zoukankan      html  css  js  c++  java
  • Android_TextVIew_flow_ex1

    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.app6.MainActivity" >
    
        <com.example.TextView_flow.marqueeText
            android:id="@+id/textView_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" 
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"/>
        <!--  TextView可以用其子类来声明,子类的表现形式是包名+类名
                设置4条语功能语句才能实现跑马灯的效果-->
        <com.example.TextView_flow.marqueeText
            android:layout_below="@id/textView_1"
            android:layout_marginTop="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" 
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"/>
    
    </RelativeLayout>

    marqueeText.java

    package com.example.TextView_flow;
    
    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.TextView;
    
    public class marqueeText extends TextView{
    
        public marqueeText(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
        }
    
        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
        }
        /*
         * 复写这个方法是第一个文本框得到了可聚焦为true的方法,以跑马灯形式显示,而其他文本框得不到
         */
        @Override
        public boolean isFocused() {
            return true;
        }
    }

    源代码:

    package com.example.TextView_flow;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    }
  • 相关阅读:
    AutoCAD 2012安装错误,与.net framework (1603错误)以及ms2005vc++的问题。
    [转载]Thrift的C#入门Demo_图文详解版
    ASPX的Timer位置没放正确,导致整页刷新,而不是UpdatePanel里的内容刷新。
    div、ul、li等无法居中问题,text-align无效 margin auto无效
    flash导入图片缩放后出现毛边、失真、锯齿、文字模糊不清晰的情况
    table居中方法之一:设置width,然后为style设置margin:auto
    ZR普转提day1
    从“四人过桥”到“N人过桥”
    Luogu P2375 [NOI2014]动物园
    Luogu P3435 [POI2006]OKR-Periods of Words
  • 原文地址:https://www.cnblogs.com/fangg/p/5583737.html
Copyright © 2011-2022 走看看