我想更改linearlayout的前景色。
这是我的代码:layout.setForeground(new ColorDrawable(getResources().getColor(R.color.svbackclr)));但是此调用需要最低api级别23。因此,如何在pre 23 api上执行相同操作。

最佳答案

正如@Gaurav建议的 FrameLayout 一样,您可以通过以下方式以编程方式使用前景色

int color = R.color.black_trans_60;
frm.setForeground(new ColorDrawable(ContextCompat.getColor(mContext, color)));

10-08 06:49