i change colour of imageview object using code, appears proving lot more difficult sounds.
here xml object:
<imageview android:id="@+id/lifesquare" android:layout_width="50dp" android:layout_height="30dp" android:background="#2a80b9" android:visibility="invisible" android:adjustviewbounds="false" android:clickable="true" android:croptopadding="false" android:padding="0dp" android:scaletype="fitstart" />
it's blue square, can see. able change line in code:
android:background="#2a80b9"
that's it! have read many posts on topic, promising had following solution:
view someview = findviewbyid(r.id.lifesquare); view root = someview.getrootview(); root.setbackgroundcolor(color.parsecolor("#fffff"));
but doesn't work. leaves colour is.
has done before, or have better ideas?
thank you.
why setting background
of root view. statement work :
imageview someview = (imageview) findviewbyid(r.id.lifesquare); someview.setbackgroundcolor(color.parsecolor("#ffffff"));
concern :
one more point imageview
has visibility invisible
:
android:visibility="invisible"
why setting invisible property imageview?
Comments
Post a Comment