2
傾斜的長方形繪製我想創建矩形繪製然後旋轉這麼右上方出現傾斜,我最終將覆蓋超過圓角的形象,在努力之下創建圖像的副本,使用一些繪製打造的Android XML
我希望使用XML使用,但它只是傾斜和邊緣從來沒有接觸對方
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<rotate
android:fromDegrees="19.5"
android:toDegrees="-19.5"
android:pivotX="-50%"
android:pivotY="0%"
>
<shape
android:shape="rectangle" >
<solid
android:color="@android:color/black" />
</shape>
</rotate>
</item>
創建繪製形狀的自定義繪製對象:但我再次失敗,會愛任何幫助嗎?謝謝
@Override
public void draw(Canvas canvas) {
int width = this.getBounds().width();
int height = this.getBounds().height();
double angle = 19.5 * (Math.PI/180.0);
double offsetX = height * Math.tan(angle);
Path path = new Path();
Paint paint = new Paint();
path.moveTo(0, 0);
path.lineTo(width, 0);
path.lineTo(width, height);
path.lineTo((int)offsetX, height);
path.close();
paint.setColor(_color);
paint.setStyle(Paint.Style.FILL);
canvas.drawPath(path, paint);
}