tags:

views:

45

answers:

3

Hi Friends,

I am new to Android app. development. I need to change the existing style at runtime or can create new styles at runtime and I need to apply it for my buttons and textviews..

Can any one suggest me?

A: 

There are several methods to do so (most of them are provided by the super class TextView):

  • setTextColor to change the color of foreground
  • setTypeface to change the font style
  • setBackgroundResource(int) to change its backgrond
  • setPadding to add padding

All of them work for EditText, Button and others, since most of them extends the TextView class. So, my suggestion is: RTFM... just kidding... read the documentation to see the available functions.

Cristian
A: 

Hey,

That things I know. But, I want to apply the styles not individual items like android:style attribute.

Can I update the styles.xml to change the styles and apply that styles at run time?

Sivalingaraja
this should be a comment
Janusz
+1  A: 

Yesterday I was trying to do something similar. This links gave me enough info:

Macarse