-4

I want to make the system with the creation of custom theme in the application,

whether it is possible to generate a theme in the code and then apply it to the activation through the setTheme() method?

If not, how can this be implemented in a different way?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • 1
    Does this answer your question? [android themes - defining colours in custom themes](https://stackoverflow.com/questions/12703757/android-themes-defining-colours-in-custom-themes) – Rahul Gaur Jan 24 '20 at 06:53
  • No, I want to create themes dynamically – koskokos_231 Jan 24 '20 at 07:11
  • I don't think you can. but if you find solution or any way to achieve this and you can't solve error in that. please ask again. also read this [how to ask a good question](https://stackoverflow.com/help/how-to-ask) – Rahul Gaur Jan 24 '20 at 07:14

1 Answers1

0

Generally, the themes can be generate in xml file with modifying colors, dimensions and styles. ( https://developer.android.com/guide/topics/ui/look-and-feel/themes )

you can change already defined theme on programmatically.

 public void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.Theme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
}

But, you can not modify xml files on runtime. if you want to change dimensions and colors of view items. You should create java classes which are stored all dimensions and colors as constant, and you can call the on your setTheme() method for set items attributes programmatically.

mrtcnkryln
  • 324
  • 2
  • 15