移动端的跨平台开发语言有很多,今天体验一些鸿蒙 ArkUI-X 运行到安卓设备上。
ArkUI 是一套构建分布式应用的声明式 UI 开发框架。它具备简洁自然的 UI 信息语法、丰富的 UI 组件、多维的状态管理,以及实时界面预览等相关能力,帮助您提升应用开发效率,并能在多种设备上实现生动而流畅的用户体验。
ArkUI-X 进一步将 ArkUI 扩展到 Android 平台,实现对接 Android 平台的适配,开发者基于一套 ArkTS 主代码,就可以构建 Android 平台的精美、高性能应用。
第一步:首先安装一下 ArkUI-X SDK
第二步:安装完会有环境检测,按需求配置
第三步:新建一个 ArkUI-X 的项目
第四步:简单粗暴,将之前写得底部导航代码拷贝过来
第五步:编译 APP,等待编译结果
第六步:将编译生成的.apk 安装到安卓设备上看一下效果
ArkTS声明式开发范式跨平台支持列表
#####版本软件和平台配套关系
public class MyApplication extends StageApplication { private static final String LOG_TAG = "HiHelloWorld";
private static final String RES_NAME = "res";
@Override public void onCreate() { Log.e(LOG_TAG, "MyApplication"); super.onCreate(); Log.e(LOG_TAG, "MyApplication onCreate"); }}
public class EntryEntryAbilityActivity extends StageActivity { @Override protected void onCreate(Bundle savedInstanceState) { Log.e("HiHelloWorld", "EntryEntryAbilityActivity"); setInstanceName("com.sany.harmony.digger:entry:EntryAbility:"); super.onCreate(savedInstanceState); }}
复制代码
在 arkts 中配置了网络权限,在安卓工程的 AndroidManifest 中也增加了相应的权限:
<uses-permission android:name="android.permission.internet"> <application android:name=".MyApplication" android:allowBackup="true" android:icon="@drawable/arkuix" android:label="@string/app_name" android:extractNativeLibs="true" android:supportsRtl="true" android:theme="@android:style/Theme.Light.NoTitleBar"> <activity android:exported="true" android:name=".entryentryabilityactivity" android:windowSoftInputMode="adjustResize |stateHidden" android:configChanges="orientation|keyboard|layoutDirection|screenSize|uiMode|smallestScreenSize|density"> <intent-filter> <action android:name="android.intent.action.main">
<category android:name="android.intent.category.launcher"> </category android:name="android.intent.category.launcher"></action android:name="android.intent.action.main"></intent-filter> </activity android:exported="true" android:name=".entryentryabilityactivity"</application</uses-permission android:name="android.permission.internet">
复制代码
评论