HarmonyOS开发:同层渲染绘制-Button组件

【鸿蒙实战开发】—— 同层渲染绘制Video和Button组件 开发者也可通过 registerNativeEmbedRule(tag: string, type: string) 指定tag标签和自定义类型。当前tag仅支持"embed"和"object",type类型则可任意指定,两个字符串参数均不区分大小写,ArkWeb内核侧将会统一转成小写,其中tag字串使用全字符串匹配,type使用字符串前缀匹配。 阅读详情

开发者可通过enableNativeEmbedMode()控制同层渲染开关。Html文件中需要显式使用embed标签,并且embed标签内type必须以“native/”开头。

同层渲染的标签背景是白色的,只支持Web组件嵌套一层Web组件。

  • 使用前请在module.json5添加如下权限。

    "ohos.permission.INTERNET"
    
  • 应用侧代码,同层渲染组件使用示例。

    // 创建NodeController
    import webview from '@ohos.web.webview';
    import {UIContext} from '@ohos.arkui.UIContext';
    import {NodeController, BuilderNode, NodeRenderType, FrameNode} from "@ohos.arkui.node";
    import {AVPlayerDemo} from './PlayerDemo';
    
    @Observed
    declare class Params {
      textOne : string
      textTwo : string
      width : number
      height : number
    }
    
    declare class nodeControllerParams {
      surfaceId : string
      type : string
      renderType : NodeRenderType
      embedId : string
      width : number
      height : number
    }
    
    // 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用。
    class MyNodeController extends NodeController {
      private rootNode: BuilderNode<[Params]> | undefined | null;
      private embedId_ : string = "";
      private surfaceId_ : string = "";
      private renderType_ :NodeRenderType = NodeRenderType.RENDER_TYPE_DISPLAY;
      private width_ : number = 0;
      private height_ : number = 0;
      private type_ : string = "";
      private isDestroy_ : boolean = false;
    
      setRenderOption(params : nodeControllerParams) {
        this.surfaceId_ = params.surfaceId;
        this.renderType_ = params.renderType;
        this.embedId_ = params.embedId;
        this.width_ = params.width;
        this.height_ = params.height;
        this.type_ = params.type;
      }
      // 必须要重写的方法,用于构建节点数、返回节点数挂载在对应NodeContainer中。
      // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新。
      makeNode(uiContext: UIContext): FrameNode | null{
        if (this.isDestroy_) { // rootNode为null
          return null;
        }
        if (!this.rootNode) { // rootNode 为undefined时
          this.rootNode = new BuilderNode(uiContext, { surfaceId: this.surfaceId_, type: this.renderType_});
          if (this.type_ === 'native/button') {
            this.rootNode.build(wrapBuilder(ButtonBuilder), {textOne: "myButton1", textTwo : "myButton2", width : this.width_, height : this.height_});
          } else if (this.type_ === 'native/video') {
            this.rootNode.build(wrapBuilder(VideoBuilder), {textOne: "myButton", width : this.width_, height : this.height_});
          } else {
            // other
          }
        }
        // 返回FrameNode节点。
        return this.rootNode.getFrameNode();
      }
    
      setBuilderNode(rootNode: BuilderNode<Params[]> | null): void{
        this.rootNode = rootNode;
      }
    
      getBuilderNode(): BuilderNode<[Params]> | undefined | null{
        return this.rootNode;
      }
    
      updateNode(arg: Object): void {
        this.rootNode?.update(arg);
      }
      getEmbedId() : string {
        return this.embedId_;
      }
    
      setDestroy(isDestroy : boolean) : void {
        this.isDestroy_ = isDestroy;
        if (this.isDestroy_) {
          this.rootNode = null;
        }
      }
    
      postEvent(event: TouchEvent | undefined) : boolean {
        return this.rootNode?.postTouchEvent(event) as boolean
      }
    }
    
    @Component
    struct ButtonComponent {
HarmonyOS Next开发学习手册——同层渲染绘制Video和Button组件 开发者也可通过 registerNativeEmbedRule(tag: string, type: string) 指定tag标签和自定义类型。当前tag仅支持"embed"和"object",type类型则可任意指定,两个字符串参数均不区分大小写,ArkWeb内核侧将会统一转成小写,其中tag字串使用全字符串匹配,type使用字符串前缀匹配。 阅读详情

相关推荐

【HarmonyOS 鸿蒙实战开发】橡皮擦案例

本示例通过 @ohos.graphics.drawing 库和 blendMode颜色混合 实现了橡皮擦功能,能够根据手指移动轨迹擦除之前绘制的内容,并且可以进行图案的撤销和恢复。

CTrup的博客 1149

GD32F303 Keil 工程项目从零搭建实战指南

本文是一份详细的GD32F303 Keil工程项目从零搭建实战指南。文章阐述了亲手搭建工程的重要性,并逐步指导开发者完成从环境准备、目录规划、工程创建、文件添加、关键配置到编译调试的全过程。重点讲解了如何正确选择启动文件、添加外设库、配置头文件路径和全局宏,旨在帮助开发者深入理解工程结构,掌握GD32F303开发的核心技能,实现从“会用”到“懂”的跨越。

weixin_29190651的博客 412

01-SA8155P 冷启动强制进入EDL模式

冷启动EDL模式

静虚待令,有物混成 3104

[图解]SysML与EA实战:住宅安全系统接口块设计全解析

本文详细解析了使用SysML和EA工具进行住宅安全系统接口块设计的全流程。从系统上下文图入门到接口块实战技巧,涵盖块定义图与内部块图的视角转换,以及多图协同建模方法论。特别分享EA工具的高效操作指南和常见问题避坑建议,帮助工程师掌握精确信号定义、端口方向设置等关键技能,提升安防系统设计效率。

weixin_29234509的博客 342

【异常】解决JDK21升级中的SecurityException: JCE无法验证BC提供者问题

本文详细解析了JDK21升级中常见的SecurityException: JCE无法验证BC提供者问题的根源与解决方案。核心在于JDK21强化了JCE安全验证,导致签名不合规的老版本Bouncy Castle库被拒绝。文章提供了通过Maven依赖树精准定位、排除旧版本并引入兼容的bcprov-jdk18on新库的完整步骤,以及清理缓存等实战技巧,帮助开发者彻底解决此兼容性问题。

weixin_29197051的博客 495

学习笔记|多样本单因素方差分析|事后比较|方差齐性|F检验|韦尔奇检验|两独立样本T检验|两样本方差分析|规范表达|《小白爱上SPSS》课程:SPSS第七讲 | 单因素方差分析怎么做?

学习笔记|多样本单因素方差分析|事后比较|方差齐性|F检验|韦尔奇检验|两独立样本T检验|两样本方差分析|规范表达|《小白爱上SPSS》课程:SPSS第七讲 | 单因素方差分析怎么做?

Medlar_CN的博客 9527

Python 爬虫教程:企业官网基本信息抓取

本文介绍了使用Python爬虫技术抓取企业官网信息的方法,包括公司名称、简介、联系方式、地址、产品及新闻等数据。通过Requests和BeautifulSoup库实现网页请求与解析,并利用Pandas存储数据为CSV文件。同时提供了应对反爬虫机制(如设置User-Agent、代理IP池、延迟请求等)的解决方案,帮助高效获取企业公开数据。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1866

[Dify实战] 项目复盘助手:自动拉数据、生成复盘报告

本文介绍如何利用Dify平台构建自动化项目复盘助手,解决传统人工复盘效率低、易遗漏等问题。系统通过自动拉取Git/Jira等数据源,计算关键指标后,由LLM生成结构化复盘报告。文章详细讲解了数据采集、指标计算、Prompt设计等核心模块的实现,并分享了完整Workflow搭建步骤。实践表明,该系统能将复盘耗时从4小时缩短至10分钟,显著提升数据准确率和执行频率。最后总结了数据一致性、输出质量等常见问题的解决方案,强调Dify+LLM组合可实现复盘流程的自动化流水线。

技术小甜甜:传播可落地技术,帮助个人和企业降低解决真实场景问题的成本 125

光学测量仿真软件:Zygo_(5).Zygo的数据处理与分析方法

通过上述综合案例,我们可以看到Zygo中的数据处理与分析方法是如何一步一步应用于实际数据的。从数据导入到预处理,再到滤波、表面分析、缺陷检测和数据可视化,每一步都至关重要,最终确保了数据的准确性和可靠性。处理后的数据还可以导出为多种格式,便于在其他软件中进行进一步的处理或报告。希望这个案例能够帮助您更好地理解和应用Zygo中的数据处理与分析方法。

kkchenjj的博客 954

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

上一篇: HarmonyOS开发:组件启动规范
下一篇: OpenHarmony开发实战:List组件的使用之设置项(ArkTS)
普通网友
博客等级 码龄5年 2986粉丝 200原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值