Monday, 15 April 2013

How to set background color with borders to perticular View dynamically in android


Hello, Today I will explain you how to set background color + borders to particular view in android.

Let's say You have one button and you have to set background color RED with border color gray, for that you have to use GradientDrawable.


 GradientDrawable drawable = new GradientDrawable();
  drawable.setShape(GradientDrawable.RECTANGLE);
  drawable.setCornerRadius(10);
  drawable.setStroke(2, Color.GRAY);
  drawable.setColor(Color.RED)); 
 
 btnBlackColor.setBackgroundDrawable(drawable);




1 comment:

  1. Its fantatic explaintion lot of information gather it...nice article....
    seo company in Chennai

    ReplyDelete