如果有人仍然有这个问题:
> xml:
android:fromDegrees="45"
android:toDegrees="0"
android:pivotX="80%"
android:pivotY="20%" >
android:height="30dp"/>
>覆盖TextView并在布局中使用它:
public class CustomTextView extends TextView {
private int mWidth;
private int mHeight;
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint mPaint = new Paint();
int color = getResources().getColor(R.color.YourColor);
mPaint.setColor(color);
Path mPath = new Path();
mPath.moveTo(.0f, this.getHeight());
mPath.lineTo(0.8f * this.getWidth(), this.getHeight());
mPath.lineTo(this.getWidth(), 0.5f * this.getHeight());
mPath.lineTo(0.8f * this.getWidth(), .0f);
mPath.lineTo(.0f, .0f);
mPath.lineTo(.0f, this.getHeight());
canvas.clipPath(mPath);
canvas.drawPath(mPath,mPaint);
}
}
关于xml示例:有两个矩形重叠.您必须大量使用这些值,这使得难以在不同的视图上使用.我认为在这种情况下使用自定义视图是最佳解决方案.