Change Background Option/Menu

0 Ben Alday · March 18, 2015
Hi there! I would like to ask how can I add an option for my users to change the apps background (much like changing its theme) Hope you guys can help, thanks~

Post a Reply

Replies

Oldest  Newest  Rating
0 Dol Lod · March 18, 2015
super.onCreate(savedInstanceState);
LayoutInflater myInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TableLayout layout = (TableLayout)myInflater.inflate(R.layout.activity_main, null); 
layout.setBackgroundColor(getResources().getColor(R.color.egg_shell));

Probably something like that is what you are looking for. Essentially, get the layout inflater, inflate the layout, and then change the resource.  Textviews can also be changed in a similar way:

TextView textview..setTextColor(m_context.getResources().getColor(R.color.aero_blue));

Using these two in conjunction with each other, you can go from white background with black text to white text in a black background.

Anyway, this is just the general idea. Additional posters could provide more specific code.
  • 1

Java / Android Development

107,323 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator