RoundedBitmapDrawable 을 사용 하여 원 각 그림 을 만 드 는 방법
                                            
 1634 단어  roundedbitmapdrawable원 각 그림
                    
 
 
Bitmap src = BitmapFactory.decodeResource(getResources(), imageId); //  Bitmap  
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), src); //  RoundedBitmapDrawable  
roundedBitmapDrawable.setCornerRadius(100); //      (      )
roundedBitmapDrawable.setAntiAlias(true); //     
image.setImageDrawable(roundedBitmapDrawable); //       원형 그림 생 성
RoundedBitmapDrawable 류 는 원형 그림 을 만 드 는 방법 을 직접 제공 하지 않 기 때문에 원형 그림 을 만 들 려 면 먼저 원본 그림 을 재단 하고 그림 을 정사각형 으로 재단 한 다음 에 원형 그림 을 생 성하 여 다음 과 같이 구체 적 으로 실현 해 야 합 니 다.
Bitmap src = BitmapFactory.decodeResource(getResources(), imageId);
Bitmap dst;
//              
if (src.getWidth() >= src.getHeight()){
dst = Bitmap.createBitmap(src, src.getWidth()/2 - src.getHeight()/2, 0, src.getHeight(), src.getHeight()
);
}else{
dst = Bitmap.createBitmap(src, 0, src.getHeight()/2 - src.getWidth()/2, src.getWidth(), src.getWidth()
);
}
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), dst);
roundedBitmapDrawable.setCornerRadius(dst.getWidth() / 2); //               
roundedBitmapDrawable.setAntiAlias(true);
image.setImageDrawable(roundedBitmapDrawable);이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Android 는 원형 그림 이나 원 각 그림 을 실현 합 니 다.Android 원형 이미지 나 원 각 이미지 의 빠 른 실현,구체 적 인 내용 은 다음 과 같 습 니 다. 말 이 많 지 않 으 면 코드 로 바로 올 려 주세요. xml 파일 레이아웃 컨트롤 을 초기 화 한 후 도구...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.