我想讓用戶選擇字體大小。如何在我自己的android應用程序中設置字體比例?
備件確實提供的功能來做到這一點,
ActivityManagerNative.getDefault()。updateConfiguration(新字體大小規模配置)
但這是整個所有的Android應用程序。我想將其添加到我的應用程序的首選項中,並且僅影響我的應用程序。
我嘗試了下面的方法,它有時會起作用,但是第一次啓動我的應用程序時,字體大小依然爲1.0。我不知道爲什麼。我在每個onCreate的活動中添加了以下代碼。
Configuration config = resources.getConfiguration(); config.fontScale = 1.5F; resources.updateConfiguration(config,mDisplayMetrics);
我該怎麼辦?
你找到了這個答案嗎?我目前遇到同樣的問題... – dineth
請參閱Activity.getResources()。setConfiguration()(或類似的東西) – njzk2