[Solved] LayerDrawable auto change background


ShapeDrawable biggerRectDrawable = new ShapeDrawable(new RectShape());
    biggerRectDrawable.getPaint().setColor(mActivity.getResources().getColor(R.color.treasure_box_content_bg));

    ShapeDrawable smallerRectDrawable = new ShapeDrawable(new RectShape());
    smallerRectDrawable.getPaint().setColor(mActivity.getResources().getColor(R.color.common_white));
    Drawable[] layers = {smallerRectDrawable, biggerRectDrawable};

    LayerDrawable layerDrawable = new LayerDrawable(layers);
    layerDrawable.setLayerInset(1, 0, mScreenWidth / 3, 0, 0);
    ViewsApiCompat.setBackground(mTreasureBoxView, layerDrawable);

problem solved. bingo.

solved LayerDrawable auto change background