Android记事本NotePad应用功能拓展(六)
一、实现功能
1.通过设置改变底部标签按钮颜色样式
2.改变标题样式
3.最终结果
二、项目代码分析
1.通过设置改变底部标签按钮颜色样式
//根据 preference.xml中的fabColor值调整fab颜色
private void chooseFabColor(int fabColor) {
switch (fabColor) {
case -500072:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.q)));
break;
case -500081:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.w)));
break;
case -500061:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.e)));
break;
case -500074:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.r)));
break;
case -500078:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.t)));
break;
case -500083:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.y)));
break;
case -500079:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.u)));
break;
case -500063:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.i)));
break;
case -500066:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.o)));
break;
case -500069:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.p)));
break;
default:
fab.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.fabColor1)));
}
}
//根据 preference.xml中的fab_alarmColor值调整fab_alarm颜色
private void chooseFabPlanColor(int fabColor) {
switch (fabColor) {
case -500072:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.q)));
break;
case -500081:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.w)));
break;
case -500061:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.e)));
break;
case -500074:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.r)));
break;
case -500078:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.t)));
break;
case -500083:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.y)));
break;
case -500079:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.u)));
break;
case -500063:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.i)));
break;
case -500066:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.o)));
break;
case -500069:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.p)));
break;
default:
fab_alarm.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.fabColor1)));
}
}
2.改变标题样式
if(!sharedPreferences.contains("noteTitle")){
editor.putBoolean("noteTitle", true);
editor.commit();
}
三、参考资料
相关参考:Android记事本NotePad应用功能拓展(一)
作者GitHub下载链接:https://github.com/KangKangBigWorld/Android/tree/master/Mid_Test