在Java程式碼裡設定控制元件圓角
阿新 • • 發佈:2019-01-31
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));