TextView
属性设置
android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/autotx"
|
注意:setText()或setTextColor()方法的参数是一个int值还是一个资源地址
android:autoLink
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/webUrl"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="email"
android:text="@string/email"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="phone"
android:text="@string/phoneNumber"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="map"
android:text="@string/mapUrl"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="map"
android:text="@string/mapUrl"
android:id="@+id/tvHtml"
/>
</LinearLayout>
带边框的TextView
自定义带边框的TextView
package cn.class3g.activity;
import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; import android.widget.TextView;
public class BorderTextView extends TextView {
public BorderTextView(Context context, AttributeSet attr) { super(context,attr); }
public void onDraw(Canvas canvas) { super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(android.graphics.Color.GREEN); canvas.drawLine(0, 0, this.getWidth() - 1, 0, paint); canvas.drawLine(0, 0, 0, this.getHeight() - 1, paint); canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint); canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, paint); } } |
<cn.class3g.activity.BorderTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:padding="30dp" android:text="xxxxxxxxxxxxx" /> |