简体   繁体   中英

How to change values in dimens.xml

Can I change variable in dimens.xml from my java code? Or it's only possible to change font size in textView through setTextSize(value) ?

Thanks for help.

Can I change variable in dimens.xml from my java code?

No, you can't. Those values are static.

Or it's only possible to change font size in textView through setTextSize(value)?

Yes, that's actually the way you're supposed to dynamically change your TextViews sizes.-

TextView yourTextView = (TextView) findViewById(R.id.yourTextView);
yourTextView.setTextSize(20);

Keep in mind, however, that you should use the dimensions defined in your dimens.xml to do that.-

yourTextView.setTextSize(getResources().getDimension(R.dimen.dimen20));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM