How to set a background color for linear layout programatically? I tried following code but not working:
LinearLayout footer = new LinearLayout(activity);
footer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 8));
footer.setBackgroundColor(Color.parseColor("##ffb5d6e1"));
((LinearLayout)v).addView(footer);
I think your issue is in your line here:
footer.setBackgroundColor(Color.parseColor("##ffb5d6e1"));
Remove the extra '#' symbol so that it is:
footer.setBackgroundColor(Color.parseColor("#b5d6e1"));
I also removed the 'ff' because you were essentially setting the opacity to 100%, which is done by default if you just only use six character long hex values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With