Do the following:
1) Get a TextView using regular findViewById() :
TextView textView = (TextView) rootView.findViewById(R.id.resourceName);
2) Get Drawable from TextView using getBackground() and drop it onto GradientDrawable :
GradientDrawable backgroundGradient = (GradientDrawable) textView.getBackground();
3) Apply it using the setStroke() method (pass its width in pixels and color):
backgroundGradient.setStroke(5, Color.BLACK);
All code:
TextView textView = (TextView) rootView.findViewById(R.id.resourceName); GradientDrawable backgroundGradient = (GradientDrawable) textView.getBackground(); backgroundGradient.setStroke(5, Color.BLACK);
eldivino87
source share