如何将imageview的大小减小到200x200?
这是我的实际代码:
private ImageView splash;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
FrameLayout fl = new FrameLayout(this.getApplicationContext());
splash = new ImageView(getApplicationContext());
splash.setImageResource(R.drawable.logo);
fl.addView(splash);
fl.setForegroundGravity(Gravity.CENTER);
fl.setBackgroundColor(Color.BLACK);
setContentView(fl);
Run Code Online (Sandbox Code Playgroud)
试试这个:
ImageView image=(ImageView)findViewById(R.id.Image1);
Bitmap bm=BitmapFactory.decodeResource(getResources(), R.drawable.sc01);
int width=200;
int height=200;
Bitmap resizedbitmap=Bitmap.createScaledBitmap(bm, width, height, true);
image.setImageBitmap(resizedbitmap);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5343 次 |
| 最近记录: |