android - Setting button background programtically removes it from screen -
i trying change background color of button programmatically when change color button disappears screen.
here button in layout
<button android:id="@+id/ibtn_ea_colorpick_new" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:background="@drawable/clr_btn" />
and here how changing background
btn_colorpick.setbackgroundcolor(btn_colorpick.getcontext().getresources().getcolor(r.color.blackcolor));
i have tried
btn_colorpick.setbackgroundcolor(getresources().getcolor(r.color.blackcolor));
but same result
try using imagebutton -
<imagebutton android:id="@+id/ibtn_ea_colorpick_new" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:src="@drawable/clr_btn" android:background="@drawable/red_color" /> btn_colorpick.setbackgroundcolor(->ur color <-);
Comments
Post a Comment