오른쪽 상단 및 오른쪽 하단 (모든 오른쪽)에서 크기 조정 된 이미지 (가운데 맞춤) 만 반올림하려면 어떻게해야합니까?오른쪽에서 이미지 크기가 반올림 된
비슷한 (TopRoundedImage, 저자 덕분에) 클래스를 찾을 수 있지만 왼쪽 상단과 오른쪽 상단에 있습니다. 나는 그것을 바꾸려고 노력하고있다. 그러나 나는 아직도 그것을 잘못하고 있다고 생각한다.
또한 글라이드를 사용하여 인터넷에서 이미지를 요청하고 오른쪽으로 만 회전하고 싶습니다.
배경 드로어 블을 사용하려했지만 작동하지 않습니다 (스케일 때문에 읽음).
public class RightRoundedImageView extends AppCompatImageView
{
private final RectF roundRect = new RectF();
private float rect_radius = 7;
private final Paint maskPaint = new Paint();
private final Paint zonePaint = new Paint();
public RightRoundedImageView(Context context, AttributeSet attrs)
{
super(context, attrs);
init();
}
public RightRoundedImageView(Context context)
{
super(context);
init();
}
private void init()
{
maskPaint.setAntiAlias(true);
maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
zonePaint.setAntiAlias(true);
zonePaint.setColor(Color.WHITE);
float density = getResources().getDisplayMetrics().density;
rect_radius = rect_radius * density;
}
public void setRectAdius(float radius)
{
rect_radius = radius;
invalidate();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
super.onLayout(changed, left, top, right, bottom);
int w = getWidth();
int h = getHeight();
// roundRect.set(0, 0, w, h + rect_radius);//round top
roundRect.set(0, 0, w + rect_radius, h); //round left
// roundRect.set(0, 0, w - rect_radius, h); //round all
}
@Override
public void draw(Canvas canvas)
{
canvas.saveLayer(roundRect, zonePaint, Canvas.ALL_SAVE_FLAG);
canvas.drawRoundRect(roundRect, rect_radius, rect_radius, zonePaint);
canvas.saveLayer(roundRect, maskPaint, Canvas.ALL_SAVE_FLAG);
super.draw(canvas);
canvas.restore();
}
}
누구든지 알고 있거나 도움을받을 수 있다면 감사하겠습니다. 감사.
을 확인? – Lingeshwaran
@Lingeshwaran 링크가 작동하는지 확인 하시려면 이미지 –