本文整理汇总了Java中android.content.res.Configuration.setLayoutDirection方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.setLayoutDirection方法的具体用法?Java Configuration.setLayoutDirection怎么用?Java Configuration.setLayoutDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.Configuration
的用法示例。
在下文中一共展示了Configuration.setLayoutDirection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateResourcesLegacy
import android.content.res.Configuration; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static Context updateResourcesLegacy(Context context, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
configuration.locale = locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLayoutDirection(locale);
}
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
return context;
}
示例2: setContextLocale
import android.content.res.Configuration; //导入方法依赖的package包/类
private static void setContextLocale(Context context, Locale selectedLocale) {
Configuration configuration = context.getResources().getConfiguration();
if (!configuration.locale.equals(selectedLocale)) {
configuration.locale = selectedLocale;
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLayoutDirection(selectedLocale);
}
context.getResources().updateConfiguration(configuration,
context.getResources().getDisplayMetrics());
}
}
示例3: updateLocale
import android.content.res.Configuration; //导入方法依赖的package包/类
private void updateLocale(@NonNull Context context, @NonNull Locale locale) {
final Resources resources = context.getResources();
Configuration config = resources.getConfiguration();
config.locale = locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
config.setLayoutDirection(config.locale);
}
resources.updateConfiguration(config, resources.getDisplayMetrics());
}
示例4: updateLocale
import android.content.res.Configuration; //导入方法依赖的package包/类
private void updateLocale(@NonNull Context context, @NonNull Locale locale) {
final Resources resources = context.getResources();
Configuration config = resources.getConfiguration();
config.locale = locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
config.setLayoutDirection(config.locale);
}
resources.updateConfiguration(config, resources.getDisplayMetrics());
}
示例5: updateResources
import android.content.res.Configuration; //导入方法依赖的package包/类
public static Context updateResources(Context context, Locale locale) {
Locale.setDefault(locale);
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
configuration.setLayoutDirection(locale);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
configuration.setLocale(locale);
return context.createConfigurationContext(configuration);
} else {
configuration.locale = locale;
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
return context;
}
}
示例6: updateResources
import android.content.res.Configuration; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.N)
private static Context updateResources(Context context, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration configuration = context.getResources().getConfiguration();
configuration.setLocale(locale);
configuration.setLayoutDirection(locale);
return context.createConfigurationContext(configuration);
}
示例7: updateConfiguration
import android.content.res.Configuration; //导入方法依赖的package包/类
/**
* This is public to allow for an activity to force the
* current locale to be applied if necessary (e.g., when
* a new activity launches).
*/
public void updateConfiguration(Context context, Locale locale) {
Resources res = context.getResources();
Configuration config = res.getConfiguration();
// We should use setLocale, but it's unexpectedly missing
// on real devices.
config.locale = locale;
config.setLayoutDirection(locale);
res.updateConfiguration(config, null);
}