0

I want to set text color for whole app,what i am doing is that,I have created color picker,When user select color from color picker,That selected color should set for whole app,I don't know how to do this..i am new in android

 This is my rgb code..
 String rgbString = "R: " + Color.red(color) + " B: " + Color.blue(color) + " G: " + Color.green(color);
Ravi
  • 95
  • 1
  • 2
  • 9

2 Answers2

1

You can create a custom TextView ,that is checking the setting. here is a tutorial for it

marcel
  • 313
  • 4
  • 10
  • but i want to set text color of whole application – Ravi Oct 27 '14 at 10:06
  • The custom textview will update when colour settings is change. Every time the custom textview is create it will check the witch colour the text should be. You should not forget the reload or update the currentview when the colour has been changed – marcel Oct 27 '14 at 10:32
  • sore for late response i had created textview,button and edit text,I want to change color of all this component.. – Ravi Oct 28 '14 at 07:21
  • Maybe you should creates theme´s for it http://stackoverflow.com/questions/18301554/android-change-app-theme-on-onclick is a example – marcel Oct 28 '14 at 08:38
0

Create a color attribute and store it in SharedPreferences and associate your full app to that color. When user select color from color picker, just change the SharedPreferences property of that color .

Why use SharedPreferences

Because you can't modify resources at runtime. Now full app text color will be changed.

textview.setTextColor(Color.argb(0,200,0,0)) //r,g,b and fourth parameter is optional 

Store three int variable r,g,b in sharedPreferences and set them as above. No need of fourth parameter

SweetWisher ツ
  • 7,296
  • 2
  • 30
  • 74
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
  • how to set this color to whole app – Ravi Oct 27 '14 at 10:10
  • You need to set the color for all `TextView` as shown in the answer...there is no shortcut that only one line will change to whole app text color.. – SweetWisher ツ Oct 27 '14 at 10:11
  • 1
    If the color is fixed, you can create `Custom Textview` and use it in the app..But as you said, the user will select the color from color picker and that color will be set to the textView..then you need to code for all textview manually. – SweetWisher ツ Oct 27 '14 at 10:15
  • i think you have to create a custom theme for it – Zar E Ahmer Oct 27 '14 at 10:23