|
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mode_lay" android:layout_width="fill_parent"
android:layout_height="fill_parent">
</RelativeLayout>
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RelativeLayout show_image = (RelativeLayout)findViewById(R.id.mode_lay);
show_image.setBackgroundColor(Color.WHITE);
ImageView imageView = new ImageView(this);
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
int size = 80;
String contentString = "1啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊1";
Bitmap mbmpTest = Bitmap.createBitmap(contentString.length()*size,size,Config.ARGB_8888);
Canvas canvasTemp = new Canvas(mbmpTest);
Paint p = new Paint();
p.setColor(Color.RED);
p.setAntiAlias(true);
p.setTextSize(size);
p.setAlpha(255);
canvasTemp.drawText(contentString,0,size,p);
imageView.setBackgroundDrawable(new BitmapDrawable(mbmpTest));
show_image.addView(imageView);
ImageView imageView2 = new ImageView(this);
imageView2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
Bitmap mbmpTest2 = Bitmap.createBitmap(200,100,Config.ARGB_8888);
Canvas canvasTemp2 = new Canvas(mbmpTest2);
Paint p2 = new Paint();
p2.setColor(Color.RED);
p2.setAntiAlias(true);
p2.setTextSize(size);
p2.setAlpha(255);
canvasTemp2.drawText("啊啊",0,size,p);
imageView2.setBackgroundDrawable(new BitmapDrawable(mbmpTest2));
show_image.addView(imageView2);
为什么上面的图片 不能正常按照正常设置的字体现实 我把它的尺寸打印出来 尺寸是设置的尺寸
可是屏幕现实 自动缩小到屏幕的宽度 而下面的图片会正常显示 求解 |
|