_安卓系统 状态栏里怎么实现动态图标">
赞
踩
<java-symbol type="string" name="status_bar_input_type" />
<item><xliff:g id="id">@string/status_bar_input_type</xliff:g></item>
注意string-array name="config_statusBarIcons"中字符串添加的顺序就是图标在状态栏从左到右显示的顺序
然后在frameworks/base/core/res/res/values/config.xml继续添加
<string translatable="false" name="status_bar_input_type">input_type</string>
private final String mSlotInputType;
private final String ACTION_INPUT_STATUS_CHANGED = "android.intent.action.INPUT_STATUS_CHANGED";
在构造方法中初始化
mSlotInputType = context.getString(com.android.internal.R.string.status_bar_input_type);
//...省略代码....
filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE);
filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE);
filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
//添加的action(非必要)
filter.addAction(ACTION_INPUT_STATUS_CHANGED);
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
case ACTION_INPUT_STATUS_CHANGED:
updateInputType(intent);
break;
private final void updateInputType(Intent intent) {
mIconController.setIcon(mSlotInputType, R.drawable.y_button, null);
mIconController.setIconVisibility(mSlotInputType, true);
}
如果安装了SystemUI.apk之后图标顺序没改变或者没显示,可能是没有编译安装framework-res.apk,因为上面修改的config.xml文件不在SystemUI模块下,所有要编译framework-res.apk才能起效。该apk在/system/framework/framework-res.apk。编译framework-res.apk命令行:
make framework-res.apk
安装apk:
adb root
adb remount
adb push 编译好的apk路径名\framework-res.apk /system/framework/framework-res.apk
重新安装完framework-res.apk状态栏会显示正常
参考链接:Android状态栏右侧添加图标并控制其显示状态_android 在通知栏右侧显示图标_coder_soldier的博客-CSDN博客
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。