If all you have to deal with is varying height, make it a 9 patch drawable. Check out the developer guide : http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch http://developer.android.com/tools/help/draw9patch.html
If you want something closer to your iOS code, you could use a Path and draw to a canvas. For example, you could create a custom drawable to do this:
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.Drawable;
public class PathDrawable extends Drawable {
Path mPath = new Path();
Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
public PathDrawable(){
mPaint.setColor(Color.GRAY);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeWidth(5);
}
@Override
public void draw(Canvas canvas) {
mPath.moveTo(10,10);
mPath.lineTo(10, canvas.getHeight()-10);
mPath.lineTo(canvas.getWidth()-50, canvas.getHeight()-10);
mPath.lineTo(canvas.getWidth()-10, canvas.getHeight()-50);
mPath.lineTo(canvas.getWidth()-10, 10);
mPath.close();
canvas.drawPath(mPath, mPaint);
}
@Override
public void setAlpha(int i) {}
@Override
public void setColorFilter(ColorFilter colorFilter) {}
@Override
public int getOpacity() {
return 0;
}
}
Here I just draw one of the shapes, but you should get the idea.