Android控件开发之TextView

来源:互联网 发布:如何复制淘宝上的图片 编辑:程序博客网 时间:2024/06/04 18:02

TextView控件就是一个字符串显示标签.

TextView效果:
 


文字左右滚动三个属性: 

[html] view plaincopy
  1. android:singleLine="true"   
  2. android:ellipsize="marquee"   
  3. android:marqueeRepeatLimit="marquee_forever"  


本程序main.xml源码

[cpp] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.       
  8. <TextView   
  9.     android:id="@+id/textview"   
  10.     android:layout_width="wrap_content"  
  11.     android:layout_alignParentBottom="true"   
  12.     android:layout_height="wrap_content"  
  13.     android:fadingEdge="horizontal"  
  14.     android:scrollHorizontally="true"   
  15.     android:singleLine="true" android:ellipsize="marquee"  
  16.     android:marqueeRepeatLimit="marquee_forever"   
  17.     android:focusable="true"  
  18.     android:focusableInTouchMode="true"  
  19.     android:text="开始我们的Android开发之旅............................(*^__^*) 嘻嘻……"  
  20.     android:textSize="14dip" />  
  21.     <!-- 如没有这不设置android:focusableInTouchMode="true"  我们会开始滚动一次 -->  
  22.   
  23.   
  24. </LinearLayout>  


  本程序java源码

[cpp] view plaincopy
  1. package com.sx.TextView;  
  2.   
  3.   
  4. import android.app.Activity;  
  5. import android.os.Bundle;  
  6.   
  7.   
  8. public class TextViewActivity extends Activity   
  9. {  
  10.     /** Called when the activity is first created. */  
  11.   
  12.     @Override  
  13.     public void onCreate(Bundle savedInstanceState)   
  14.     {  
  15.         super.onCreate(savedInstanceState);  
  16.         setContentView(R.layout.main);  
  17.             
  18.     }  
  19. }  
0 0
原创粉丝点击