LayerDrawable bgShape = (LayerDrawable) mActivity.getResources().getDrawable(R.drawable.treasure_box_bg);
if (bgShape != null) {
((ShapeDrawable) bgShape.getDrawable(1)).setPadding(0, mScreenWidth / 3, mScreenWidth, mWindowHeight);
ViewsApiCompat.setBackground(mTreasureBoxView, bgShape);
}
答案 0 :(得分:0)
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);
问题解决了。宾果游戏。