背景大小变化了

Vin*_*ins 0 user-interface android android-layout

我正在以编程方式更改按钮的背景颜色,如下所示

     Button button =(Button)findViewById(R.id.one);
    button.setBackgroundColor(0xFFFF0000);
Run Code Online (Sandbox Code Playgroud)

但在此之后按钮的大小增加..我在UI中使用相对布局.

Mic*_*ael 6

默认按钮背景drawable具有某种边距.这些边距只是图像两侧的透明像素.为按钮设置背景颜色时,这些边距消失,因为按钮的整个矩形都填充了颜色.