【Harmony OS】【FAQ】鸿蒙问题合集1
1、【ArkUI】eTS方式显示Toast
import prompt from '@system.prompt'@Entry@Componentstruct Index { build() { Column() { Row() { Button("Hello Button") .fontColor(Color.White) .fontSize(20) .padding(20) .onClick(() => { prompt.showToast({message: 'Hello,I am Toast',duration: 2000,bottom: 200 }) }) } }.backgroundColor(Color.Black) .width('100%') .height('100%') }}
显示效果:
2、【DevEco Device Tool】无法找到工具对应下载链接
HarmonyOS官网无法找到DevEco Device Tool工具对应下载链接
1、当前工具临时下线优化中,预计12月30日(星期四)会上线3.0Beta2版本
2、可以通过账号登录此链接,DP平台-集成开发页签可以下载
3、【Java UI】如何调试鸿蒙应用运行至真机
真机运行调试应用需要先获取udid,然后在AGC控制台添加设备信息。
获取UDID命令行如下:
adb shell bm get -u
可以参考官方网站应用调试指南:文档中心
编译生成hap包指南:文档中心
4、【ArkUI】ets开发时,如何设置组件的最小宽度或者最大宽度?
可以参考以下API方式可以设置最大和最小宽度:
/** * constraint Size: * minWidth:minimum Width,maxWidth:maximum Width,minHeight:minimum Height ,maxHeight:maximum Height, * @since 7 */constraintSize(value: { minWidth?: number | string | Resource; maxWidth?: number | string | Resource; minHeight?: number | string | Resource; maxHeight?: number | string | Resource;}): T;
以下为ets代码:
@Entry@Componentstruct Second { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text('Hello World') .fontSize(50) .fontWeight(FontWeight.Bold) .constraintSize({ minWidth: 100, maxWidth: 200, minHeight: 100, maxHeight: 200 }) } .width('100%') .height('100%') }}
5、【Java UI】真机调试时生成的app的名字一直都是entry_Mainability 如何自定义名字呢?
请在对应资源目录resource→base→element→string.json文件中的name和value,每个语言对应的都需要修改:
{ "string": [ { "name": "entry_MainAbility", "value": "entry_MainAbility" } ]}
欲了解更多更全技术文章,欢迎访问:https://developer.huawei.com/consumer/cn/forum/topic/0203810194016170224?fid=0101587866109860105?ha_source=zzh |