I want to add border from all sides to my RelativeLayout
at runtime. I am able to get the border, however it is changing the background color of the layout. If I set the background color to white
, it is also changing the border color to white. How do I avoid that?
Here is my code below:
private static void drawBorder(Context context, View layout){
final RectShape rect = new RectShape();
final ShapeDrawable rectShapeDrawable = new ShapeDrawable(rect);
final Resources res = context.getResources();
final Paint paint = rectShapeDrawable.getPaint();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.BLUE);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(10);
layout.setBackgroundDrawable(rectShapeDrawable); //Testing on phone with API < 16
}
Thanks.