How to change color of drawable shapes in android

前端 未结 6 897
时光取名叫无心
时光取名叫无心 2020-12-09 15:09

I am developing small android application in which I set drawable resource as background for linear layout. Now what I want to do change background color of linear layout dy

6条回答
  •  春和景丽
    2020-12-09 16:05

    The following works great for setting the color of the drawable programmatically without changing its shape:

    parentLayout.getBackground().setColorFilter(
        Color.BLACK,
        PorterDuff.Mode.SRC_ATOP
    );
    

提交回复
热议问题