WEB开发网
开发学院手机开发Android 开发 Android 开发TextView 部分字符高亮 阅读

Android 开发TextView 部分字符高亮

 2010-08-26 00:02:00 来源:WEB开发网   
核心提示:android:layout_width="fill_parent"android:layout_height="fill_parent">< TextViewandroid:text="HelloText1"android:layout_widt

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

< TextView

android:text="HelloText1"

android:layout_width="fill_parent"

android:layout_height="wrap_content" />

< /LinearLayout>

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:id="@+id/layout"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

< TextView

android:text="HelloText1"

android:layout_width="fill_parent"

android:layout_height="wrap_content" />

< /LinearLayout>

* 具体使用:

Java代码

public class TextHighlightUsage extends Activity {

TextHighlightHelper tHelper1;

TextHighlightHelper tHelper2;

LinearLayout ll;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

ll = (LinearLayout)findViewById(R.id.layout);

//Text:HelloText2

CharSequence c1 = "HelloText2";

tHelper1 = new TextHighlightHelper(this,LinearLayout.HORIZONTAL);

tHelper1.addText(c1);

tHelper1.addColor(0, 3, Color.RED);

tHelper1.addBackResource(R.drawable.dot);

ll.addView(tHelper1.loadView());

//Text:创新源于模仿!

CharSequence c2 = "创新源于模仿!";

tHelper2 = new TextHighlightHelper(this,LinearLayout.VERTICAL);

tHelper2.addText(c2);

tHelper2.addColor(1, 3, Color.RED);

ll.addView(tHelper2.loadView());

}

上一页  1 2 3 4  下一页

Tags:Android 开发 TextView

编辑录入:coldstar [复制链接] [打 印]
赞助商链接