From 6b53e817ea0b9ce62e8a96f4d7d94107ddef2aa8 Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Mon, 5 Jul 2021 19:10:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphics/Canvas.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/graphics/Canvas.md b/graphics/Canvas.md index 11246dd..88a2bdc 100644 --- a/graphics/Canvas.md +++ b/graphics/Canvas.md @@ -66,4 +66,17 @@ Canvas canvas = new Canvas(new Texture(pixelMap)); >+ openharmony API: `ohos.agp.render.Canvas` >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 ->+ 实现方案:使用`drawLine(Point point1 ,Point point2,Paint)`方法 \ No newline at end of file +>+ 实现方案:使用`drawLine(Point point1 ,Point point2,Paint)`方法 + +### **drawRoundRect(RectF rect, float rx, float ry, Paint paint)** +>+ openharmony API: `ohos.agp.render.Canvas` +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:使用`drawRoundRect(RectFloat rect, float radiusX, float radiusY, Paint paint)`方法 + +### **drawText(String text, float x, float y, Paint paint)** +>+ openharmony API: `ohos.agp.render.Canvas` +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:使用`drawText(Paint paint, String text, float x, float y)`方法 + -- Gitee From e631133955604053a831cb94de67a537babde84a Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Tue, 6 Jul 2021 10:34:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphics/drawable/Drawable.md | 11 ++++++++++- graphics/drawable/LayerDrawable.md | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 graphics/drawable/LayerDrawable.md diff --git a/graphics/drawable/Drawable.md b/graphics/drawable/Drawable.md index f787825..d8e01d6 100644 --- a/graphics/drawable/Drawable.md +++ b/graphics/drawable/Drawable.md @@ -1,4 +1,13 @@ -### **draw(Canvas canvas)** +### **Drawable()** +>+ openharmony API: ohos.agp.components.element.ShapeElement +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: +```java + ShapeElement shapeElement = new ShapeElement(); +``` + +### **draw(Canvas canvas)** >+ openharmony API: ohos.agp.components.element.Element.drawToCanvas >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 diff --git a/graphics/drawable/LayerDrawable.md b/graphics/drawable/LayerDrawable.md new file mode 100644 index 0000000..53b5276 --- /dev/null +++ b/graphics/drawable/LayerDrawable.md @@ -0,0 +1,8 @@ +### **LayerDrawable()** +>+ openharmony API: ohos.agp.components.element.ShapeElement +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: +```java + ShapeElement shapeElement = new ShapeElement(); +``` -- Gitee From 7b60c299c8d4dc6bb71be3494cce0dd390b3856b Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Mon, 19 Jul 2021 17:21:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/Display.md | 12 +++++++++++ view/LayoutInflater.md | 12 +++++++---- view/View.md | 22 +++++++++++++++++--- view/ViewPager.md | 13 ------------ view/WebView.md | 47 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 view/Display.md delete mode 100644 view/ViewPager.md create mode 100644 view/WebView.md diff --git a/view/Display.md b/view/Display.md new file mode 100644 index 0000000..d14bb34 --- /dev/null +++ b/view/Display.md @@ -0,0 +1,12 @@ +### **getSize** +>+ openharmony API: ohos.agp.window.service.Display.getSize +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用 + +```java +//获取屏幕分辨率 +Optional display = DisplayManager.getInstance().getDefaultDisplay(context); +Point pt = new Point(); +display.get().getSize(pt); +``` \ No newline at end of file diff --git a/view/LayoutInflater.md b/view/LayoutInflater.md index e283e06..7494c9d 100644 --- a/view/LayoutInflater.md +++ b/view/LayoutInflater.md @@ -1,5 +1,9 @@ ### **inflate** ->+ openharmony API:ohos.agp.components.LayoutScatter.parse ->+ openharmony SDK版本:2.1.1.21 ->+ IDE版本:2.1.0.501 ->+ 实现方案:直接替换 \ No newline at end of file +>+ openharmony API: ohos.agp.components.LayoutScatter.parse +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + +```java +rootLayout = LayoutScatter.getInstance(getContext()).parse(ResourceTable.Layout_styleable_layout, null, true); +``` \ No newline at end of file diff --git a/view/View.md b/view/View.md index 86e424b..bae092f 100644 --- a/view/View.md +++ b/view/View.md @@ -58,21 +58,18 @@ >+ 实现方案:在构造函数调用setTouchEventListener(Component.TouchEventListener listener),自定义Component实现Component.TouchEventListener接口,重写onTouchEvent(MotionEvent event)方法。 ### **onScrollChanged** - >+ openharmony API: ohos.agp.components.ComponentTreeObserver.addScrolledListener >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 >+ 实现方案:在构造函数调用getComponentTreeObserver().addScrolledListener(ComponentTreeObserver.ScrollChangedListener listener),自定义Component实现ComponentTreeObserver.ScrollChangedListener接口,onScrolled()方法。 ### **invalidate** - >+ openharmony API: ohos.agp.components.Component.invalidate >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 >+ 实现方案:在onDraw()方法中调用直接invalidate()方法无效,需在asyncDispatch方法中调用,如下:getContext().getUITaskDispatcher().asyncDispatch(this::invalidate)。 ### **setTag(int key, final Object tag)** - >+ openharmony API: ohos.agp.components.Component.setTag >+ openharmony SDK版本:2.1.0.13以上 @@ -85,3 +82,22 @@ tag.put(1, "testTag"); image.setTag(tag); ``` +### **setMeasuredDimension** +>+ openharmony API: ohos.agp.components.Component.setEstimatedSize +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用, 写在 `onEstimateSize` 方法的实现代码中 + +```java +// 需要先要调用 setEstimateSizeListener +public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) { + // 第二个参数要设置为 Component.EstimateSpec.NOT_EXCEED + setEstimatedSize( + Component.EstimateSpec.getChildSizeWithMode(size.width, size.width, Component.EstimateSpec.NOT_EXCEED), + Component.EstimateSpec.getChildSizeWithMode(size.height, size.height, Component.EstimateSpec.NOT_EXCEED) + ); + + // 要返回 true + return true; +} +``` diff --git a/view/ViewPager.md b/view/ViewPager.md deleted file mode 100644 index 0255410..0000000 --- a/view/ViewPager.md +++ /dev/null @@ -1,13 +0,0 @@ - -# PageSlider -* openharmony API: ohos.agp.components.PageSlider -* openharmony SDK版本:2.1.1.21 -* IDE版本:2.1.0.501 -* 实现方案: - -openharmony: - -``` java - bannerView = (PageSlider)findComponentById(ResourceTable.Id_page_slider); - bannerView.setProvider(new TabPagerProvider(this, titles)) -``` \ No newline at end of file diff --git a/view/WebView.md b/view/WebView.md new file mode 100644 index 0000000..e0dbc2d --- /dev/null +++ b/view/WebView.md @@ -0,0 +1,47 @@ +### **loadUrl** +>+ openharmony API: ohos.agp.components.webengine.WebView.load +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:直接替换 + +### **getSettings** +>+ openharmony API: ohos.agp.components.webengine.WebView.getWebConfig +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:直接替换 + +### **canGoBack** +>+ openharmony API: ohos.agp.components.webengine.WebView.getNavigator().canGoBack +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:代码如下 +```java +webView.getNavigator().canGoBack(); +``` + +### **goBack** +>+ openharmony API: ohos.agp.components.webengine.WebView.getNavigator().goBack +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:代码如下 +```java +webView.getNavigator().goBack(); +``` + +### **canGoForward** +>+ openharmony API: ohos.agp.components.webengine.WebView.getNavigator().canGoForward +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:代码如下 +```java +webView.getNavigator().canGoForward(); +``` + +### **goForward** +>+ openharmony API: ohos.agp.components.webengine.WebView.getNavigator().goForward +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.2.0.200 +>+ 实现方案:代码如下 +```java +webView.getNavigator().goForward(); +``` \ No newline at end of file -- Gitee