布局代码:<LinearLayout 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:orientation="vertical" tools:context=".MainActivity" > <com.imooc.primer.MarqueeTest android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:singleLine="true" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/marquee1" /> <com.imooc.primer.MarqueeTest android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="24dp" android:ellipsize="marquee" android:singleLine="true" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/marquee2" /></LinearLayout>主程序代码:public class MarqueeTest extends TextView{ public MarqueeTest(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } public MarqueeTest(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } public MarqueeTest(Context context) { super(context); // TODO Auto-generated constructor stub } public boolean isFoused(){ return true; }}清单文件设置了。<activity android:name="com.imooc.primer.MarqueeTest"></activity>
2 回答
- 2 回答
- 0 关注
- 1286 浏览
添加回答
举报
0/150
提交
取消