방법

2016-07-02 3 views
0

이 어떻게 API를 뒤로 23방법

public class CustomImageViewCircularShape extends ImageView { 

    public static float radius = 100.0f; 

    public CustomImageViewCircularShape(Context context) { 
     super(context); 
    } 

    public CustomImageViewCircularShape(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public CustomImageViewCircularShape(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    @Override 
    protected void onDraw(Canvas canvas) { 
     Path clipPath = new Path(); 
     RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight()); 
     clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW); 
     canvas.clipPath(clipPath); 
     super.onDraw(canvas); 
    } 
} 

하지만 API 16도 안드로이드 스튜디오는 경고를 제공하지 않습니다 작동하지 관련 circularImageView을 얻고있다 API를 <20 (안드로이드)에 원형 이미지보기를 얻을 수 있습니다 지원하다 ? 왜 그것이 작동하지 않거나 내가 오래된 Apis에서 작동하게 만들 수있는 아이디어?

+1

어쩌면이 라이브러리는 내가 찾던 당신이 https://github.com/hdodenhof/CircleImageView – Harry

+0

@harry 정확히 도움이 될 수 있습니다

당신 같은 접근 방식에 대한

http://frescolib.org/docs/rounded-corners-and-circles.html

이 하나의 시도 –

+0

감사를 추가하는 것을 잊어 버렸습니다 : D @harry –

답변

1

또 다른 방법으로 페이스 북의 Fresco 라이브러리를 사용할 수 있습니다. 모든 기능 중에서 원형 이미지를 사용할 수 있습니다.

여기에 더 많은 정보가 있습니다. https://gist.github.com/melanke/7158342

+1

주셔서 감사합니다 :), 당신의 노력에 감사드립니다. 해리의 도서관이 일을 했어. –