我想在选择应用偏好后将样式应用到我的应用。
以下是我的MainActivity.java中的相关部分:
private void loadPreferences(){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean Background = sharedPreferences.getBoolean("background_color", false);
if (Background){
LinearLayout mainLayout = (LinearLayout)findViewById(R.id.mainActivityLayout);
}
^我想在(背景)部分中应用样式。
答案 0 :(得分:1)
继续使用此颜色而不是白色。
if (Background){
LinearLayout mainLayout = (LinearLayout)findViewById(R.id.mainActivityLayout);
mainLayout.setBackgroundColor(Color.WHITE);
}
答案 1 :(得分:0)
我不相信你可以以编程方式设置样式。但是,您可以使用模板布局xml来解决它,或者您可以为视图创建自定义类