跑马灯循环三次?
跑马灯跑了三个循环之后,就停止了。 1. 这个只是我的这样么? 2.如果想限制次数或者无限循环的话,是否也能实现?
跑马灯跑了三个循环之后,就停止了。 1. 这个只是我的这样么? 2.如果想限制次数或者无限循环的话,是否也能实现?
2015-12-12
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.textview.MainActivity" > <com.example.textview.MarqueeText android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/hello_Text" /> <com.example.textview.MarqueeText android:id="@+id/textView2" android:layout_below="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/hello_Text" /> </RelativeLayout>
MarqueeText.java
package com.example.textview;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
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
}
public boolean isFocused(){
return true;
}
}strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Textview</string> <string name="hello_world">Hello world!</string> <string name="action_settings">Settings</string> <string name="hello_Text">我是一个长的TextView,我是一个长的TextView,我是一个长的TextView</string> </resources>
举报