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. w3webschool provide online wordpress training.
    WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL. We at W3 web School provide WordPress training in Kolkata. We also provide online wordpress training in India for working professionals and those who reside in far flung areas.So our training course in oriented for both live classes and also Online WordPress training for who want to learn WordPress from home at their comfort and convenience.

    ReplyDelete