1. 程式人生 > >在Java程式碼裡設定控制元件圓角

在Java程式碼裡設定控制元件圓角

LinearLayout layout = (LinearLayout) findViewById(R.id.layout); 
Drawable drawable = getResources().getDrawable(R.drawable.bg); 
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; 
Bitmap bitmap = bitmapDrawable.getBitmap(); BitmapDrawable bbb = new BitmapDrawable(toRoundCorner(bitmap, 30)); 
layout.setBackgroundDrawable(bbb);  //ImageView imageView = (ImageView) findViewById(R.id.imgShow);  //imageView.setImageBitmap(MyActivity.getRoundedCornerBitmap(bitmap));  //imageView.setImageBitmap(MyActivity.toRoundCorner(bitmap, 20));