[英]Battery Icon from xposed
我想知道如何使用xposed模塊跟蹤電池,卸下現有的電池表並動態添加自己的電池表。 我不知道如何開始。 我看到了一些源代碼,但不明白它們是如何工作的。 請提供一些示例或基本思想以開始使用(鏈接也將非常有幫助)
以下是我的ROM(CoolUI8)中的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center_vertical" android:id="@id/system_icons" android:layout_width="wrap_content" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.keyguard.AlphaOptimizedLinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<include android:id="@id/msim_hd_voice_on" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="2.0dip" layout="@layout/hd_voice_on" />
<include android:id="@id/msim_signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="2.0dip" layout="@layout/signal_cluster_view_yulong" />
<com.android.systemui.BatteryViewGroup android:id="@id/battery_field" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="4.0dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.Text.Style" android:layout_gravity="center_vertical" android:id="@id/battery_level" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="@dimen/battery_level_padding_end" />
<FrameLayout android:layout_gravity="center_vertical" android:id="@id/battery_group" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:id="@id/battery_frame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/stat_sys_battery_frame" android:scaleType="center" />
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="25.0dip" android:layout_height="12.0dip" />
<ImageView android:id="@id/battery_charge" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="25.0dip" android:src="@drawable/stat_sys_battery_charge_flag" android:scaleType="center" />
</FrameLayout>
</com.android.systemui.BatteryViewGroup>
</LinearLayout>
我已經成功地隱藏了現有的電池電量表(使用ID:battery_group隱藏了整個FrameLayout),但是我想在那里添加自定義電池電量表...如果您有與此主題相關的任何信息,請回復:
我在xposed模塊中用黑色替換了WhatsApp的藍色刻度。 我認為您的問題類似於我的問題。
我不知道這是否對您有幫助,但會幫助您開始使用xposed。
您可以從IXposedHookInitPackageResources接口實現此方法
@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam initPackageResourcesParam) throws Throwable {
if (!initPackageResourcesParam.packageName.equals("com.whatsapp"))
return;
//create the resource instance for your package
modRes = XModuleResources.createInstance(MODULE_PATH, initPackageResourcesParam.res);
//example to change xml attribute like dimension
initPackageResourcesParam.res.setReplacement("com.whatsapp", "dimen", "tab_height", modRes.fwd(R.dimen.tab_height));
//example to replace icon -- battery icon in your case
initPackageResourcesParam.res.setReplacement("com.whatsapp", "drawable", "message_got_read_receipt_from_target", modRes.fwd(R.mipmap.ic_black_tick_conv));
initPackageResourcesParam.res.setReplacement("com.whatsapp", "drawable", "message_got_read_receipt_from_target_onmedia", modRes.fwd(R.mipmap.ic_black_tick_conv));
initPackageResourcesParam.res.setReplacement("com.whatsapp", "drawable", "msg_status_client_read", modRes.fwd(R.mipmap.ic_black_tick_main));
}
您可以參考我的xposed模塊代碼以查看xposed的一些示例
https://github.com/suraj0208/WhatsappExtensions
最后一件事,如果這可以幫助您接受它作為答案。 左側的刻度圖標:D
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.