格式化字符串长度,超出部分显示省略号,区分汉字跟字母
来源:互联网 发布:gta5渣电脑神优化20桢 编辑:程序博客网 时间:2024/05/16 18:14
- package com.eoeandroid.demo.testcode;
- import android.app.Activity;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.graphics.Matrix;
- import android.graphics.drawable.BitmapDrawable;
- import android.os.Bundle;
- import android.view.ViewGroup.LayoutParams;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ImageView.ScaleType;
- public class bitmaptest extends Activity {
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setTitle("eoeAndroid教程: 缩放和旋转图片 -by:IceskYsl");
- LinearLayout linLayout = new LinearLayout(this);
-
- Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
- R.drawable.eoe_android);
-
- int width = bitmapOrg.getWidth();
- int height = bitmapOrg.getHeight();
-
- int newWidth = 200;
- int newHeight = 200;
-
- float scaleWidth = ((float) newWidth) / width;
- float scaleHeight = ((float) newHeight) / height;
-
- Matrix matrix = new Matrix();
-
- matrix.postScale(scaleWidth, scaleHeight);
-
- matrix.postRotate(45);
-
- Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
- width, height, matrix, true);
-
- BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
-
- ImageView imageView = new ImageView(this);
-
- imageView.setImageDrawable(bmd);
-
- imageView.setScaleType(ScaleType.CENTER);
-
- linLayout.addView(imageView,
- new LinearLayout.LayoutParams(
- LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT
- )
- );
-
- setContentView(linLayout);
- }
- }
- package com.eoeandroid.demo.testcode;
- import android.app.Activity;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.graphics.Matrix;
- import android.graphics.drawable.BitmapDrawable;
- import android.os.Bundle;
- import android.view.ViewGroup.LayoutParams;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ImageView.ScaleType;
- public class bitmaptest extends Activity {
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setTitle("eoeAndroid教程: 缩放和旋转图片 -by:IceskYsl");
- LinearLayout linLayout = new LinearLayout(this);
-
- Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
- R.drawable.eoe_android);
-
- int width = bitmapOrg.getWidth();
- int height = bitmapOrg.getHeight();
-
- int newWidth = 200;
- int newHeight = 200;
-
- float scaleWidth = ((float) newWidth) / width;
- float scaleHeight = ((float) newHeight) / height;
-
- Matrix matrix = new Matrix();
-
- matrix.postScale(scaleWidth, scaleHeight);
-
- matrix.postRotate(45);
-
- Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
- width, height, matrix, true);
-
- BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
-
- ImageView imageView = new ImageView(this);
-
- imageView.setImageDrawable(bmd);
-
- imageView.setScaleType(ScaleType.CENTER);
-
- linLayout.addView(imageView,
- new LinearLayout.LayoutParams(
- LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT
- )
- );
-
- setContentView(linLayout);
- }
- }
0 0