Summary of Android color setting methods

Summary of Android color setting methods

There are several methods to set the interface background and text color in Android. The following describes several methods to set the color in Android from simple to deep:

1. Set directly in the layout file:

2. Extract the color to form a resource and put it under the resource file (values / drawable / color. XML):

Then use in the layout file:

Or in a java file

The above two methods are mainly based on the layout file, and the degree of freedom is not large.

3. Dynamic setting in java files mainly takes two forms:

(1) Use the subclass colordrawable of drawable

(2) Use drawable directly

Get resource getresources(), and get drawable through two drawable IDS: resources. Getdrawable (int ID)

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>