I'm trying to set color to a button, but when I write:
button.setBackgroundColor(getResources().getColor(R.color.white));
the button becomes white, but also some space around it (I have couple of buttons in linearLayout
, so it looks like one big white button).
Anyone knows how to fix this?
Update: My XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:weightSum="2"
android:layout_weight="1"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:background="@android:color/white"
android:id="@+id/button1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
/>
</LinearLayout>
Here the left button looks bigger then the right one because I changed its color