4

I would like the user to be able to edit the font size and font style from within my app. The app should just call the default settings.

enter image description here example:

 displayBtn = (Button) findViewById(R.id.displayBtn);
    displayBtn .setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(Settings.ACTION_DISPLAY_SETTINGS));
        }
    });
Tohhier Allie
  • 73
  • 1
  • 8

1 Answers1

0

XML is not editable in run time so you can are going to have to set a static value for the font size and then manually set them in the applicaiton.

For example..

public static int defaultFontSize = defaultValue;

//Update the value when the user changes font..
ClassName (class where you declared the static variable).defaultFontSize = 10;

textView.setTextSize(ClassName.defaultFontSize);
fsebek
  • 389
  • 2
  • 9
  • Thanks Feddy. I still don't understand why font style and font size cannot be called via Intent. Surely if other children of display settings can be called why not this? e.g. Wallpaper by startActivity(new Intent("android.intent.action.SET_WALLPAPER")); – Tohhier Allie Apr 21 '16 at 13:31
  • Are you looking for this? android.intent.action.FONT_CONFIG_CHANGED – fsebek Apr 21 '16 at 13:42
  • I saw that solution here: [link](http://stackoverflow.com/questions/11805808/android-is-there-intent-action-of-font-setting-changed) It doesnt work. – Tohhier Allie Apr 21 '16 at 13:48
  • Found this, but I will test myself now. http://stackoverflow.com/questions/21554419/android-androidconfigchanges-value-for-font-style-change-in-samsung-device – fsebek Apr 21 '16 at 13:53
  • I have looked at it and calling startActivity(new Intent(Settings.ACTION_DISPLAY_SETTINGS)); is certainly not the way to go. The best alternative is to create your own fragment view with different text sizes and font and setting in the applicaiton. Create a customization class which has a TypeFace and a text size settings and simply reference that class when you set the font of views in the application. This solution is more flexible and it will also allow you to add your own custom fonts! – fsebek Apr 21 '16 at 13:57
  • This sounds like a better solution. Thank you! – Tohhier Allie Apr 21 '16 at 14:02
  • If you have any more questions let me know. – fsebek Apr 21 '16 at 14:04