```c++
a[6] = 5;
000A4EF8 mov ecx,4
000A4EFD imul edx,ecx,6
000A4F00 mov dword ptr a[edx],5
a[7] = 5;
000A4F08 mov eax,4
000A4F0D imul ecx,eax,7
000A4F10 mov dword ptr a[ecx],5
这汇编代码怎么这么奇怪 啊,第二行edx=ecx乘6,那它不就等于24了嘛?之后a[24]=5??
a[6] = 5 是对数组 a 中的第 6 个元素赋值为整数 5。因为 C++ 中的数组下标从 0 开始,所以这里是对数组中的第七个元素进行操作。
000A4EF8 mov ecx,4 是将寄存器 ecx 的值设置为 4。在该行代码后面的代码中,ecx 寄存器被用来计算数组元素的位置。
000A4EFD imul edx,ecx,6 是将寄存器 edx 的值设置为 ecx 乘以 6 的结果,这是为了计算要赋值的元素在数组中的偏移量。
新建的工程,图标不是直接用的 drawable 下的图片,是这样用的,
android:roundIcon="@mipmap/ic_launcher_round"
ic_launcher_round.xml 内容如下,
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
ic_launcher_background.xml 内容如下,
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#4DDC84"
android:pathData="M0,0h108v108h-108z" />
// ...
>
为了改出差异,将 main 目录下的 ic_launcher_background.xml 文件 拷贝到 qudao1 、qudao2 目录下,并放在对应的目录下(目录要一致,这很重要),
然后修改 android:fillColor 属性,换成不同的颜色就可以了。
引申,要用不同的资源文件,需要在对应渠道的对应目录下放入main文件夹下的同名文件,保证目录结构一样,然后修改渠道下的文件就可以了。
icon 、lable 、roundIcon 属性都是这样改。
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
有个点 mark 一样。Build Variants 切到 qudao1 时,修改 qudao1 下的 xml 才会有代码提示、并且不爆红。
so ,需要修改哪个渠道的东西,还是要先切到该渠道。