Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change foreground color of a layout programmatically

Tags:

android

I want to change the foreground color of a linearlayout. This is my code:layout.setForeground(new ColorDrawable(getResources().getColor(R.color.svbackclr))); But this call require minimum api level 23.So how to do the same on pre 23 api.

like image 320
tahmidul hossain Avatar asked Nov 10 '16 05:11

tahmidul hossain


1 Answers

As @Gaurav suggested FrameLayout you can use the forground color by programatically in the following way

int color = R.color.black_trans_60;
frm.setForeground(new ColorDrawable(ContextCompat.getColor(mContext, color)));
like image 174
Raju Avatar answered Nov 15 '22 20:11

Raju