((TextView)findViewById(R.id.text)).setText(Html.fromHtml("X<sup>2</sup>"));
package samples.test;
public class MyTextView extends TextView {
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyTextView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Rect rect = new Rect();
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.WHITE);
paint.setStrokeWidth(3);
getLocalVisibleRect(rect);
canvas.drawRect(rect, paint);
}
}
<?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">
<samples.test.MyTextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
</LinearLayout>
回家休息了20多天 嘿嘿今天看见别人做了一个右上角图标的东西,感觉不错 本以为是用.9.png格式实现的原来不是
仔细看了一下原来如下:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/discounts_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我要进行测试"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_marginTop="40dp"
android:layout_marginLeft="20dp"/>
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="/blog_article/@drawable/a1/index.html"
android:layout_centerInParent="true"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text
android:text="20"
android:layout_centerInParent="true" />
</RelativeLayout>
</FrameLayout>