TextView控件就是一个字符串显示标签.
TextView效果:
文字左右滚动三个属性:
- android:singleLine="true"
- android:ellipsize="marquee"
- android:marqueeRepeatLimit="marquee_forever"
本程序main.xml源码
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <TextView
- android:id="@+id/textview"
- android:layout_width="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_height="wrap_content"
- android:fadingEdge="horizontal"
- android:scrollHorizontally="true"
- android:singleLine="true" android:ellipsize="marquee"
- android:marqueeRepeatLimit="marquee_forever"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:text="开始我们的Android开发之旅............................(*^__^*) 嘻嘻……"
- android:textSize="14dip" />
- <!-- 如没有这不设置android:focusableInTouchMode="true" 我们会开始滚动一次 -->
- </LinearLayout>
本程序java源码
- package com.sx.TextView;
- import android.app.Activity;
- import android.os.Bundle;
- public class TextViewActivity extends Activity
- {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
- }