Android修改特定语言下的字体大小

修改泰国需求,默认第一次设置为泰语字体大小为1.08倍

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

///modify{@

import java.util.Locale;

import android.content.SharedPreferences;

import android.content.SharedPreferences.Editor;

///@}



protected void onConfigurationChanged(Configuration newConfig) {

///modify{@

thFont(newConfig);

///@}

updateResources();

updateDisplaySize(); // populates mDisplayMetrics

super.onConfigurationChanged(newConfig); // calls refreshLayout



if (DEBUG) {

Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration());

}



repositionNavigationBar();

updateRowStates();

mScreenPinningRequest.onConfigurationChanged();

mNetworkController.onConfigurationChanged();

}

/// modify{@

private void thFont(Configuration newConfig){

if (newConfig != null) {

Locale locale = newConfig.locale;

String lan = locale.getLanguage();

if ("th".equals(lan)){

SharedPreferences sp = mContext.getSharedPreferences("th_font", Context.MODE_PRIVATE);

boolean isFirstTime = sp.getBoolean("isFirst", false);

if (isFirstTime) {

return;

}

final float currentScale = Settings.System.getFloat(mContext.getContentResolver(),Settings.System.FONT_SCALE, 1.0f);

if (currentScale < 1.08f){

Settings.System.putFloat(mContext.getContentResolver(), Settings.System.FONT_SCALE, 1.08f);

Editor editor = sp.edit();

editor.putBoolean("isFirst", true);

editor.apply();

}

}

}

}

///@}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值