成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

安卓VS鴻蒙第三方件切換寶典 V2.0(第一部分)

系統
文章由鴻蒙社區產出,想要了解更多內容請前往:51CTO和華為官方戰略合作共建的鴻蒙技術社區https://harmonyos.51cto.com

[[401683]]

 想了解更多內容,請訪問:

51CTO和華為官方合作共建的鴻蒙技術社區

https://harmonyos.51cto.com

眾所周知,安卓應用開發經過這么多年的發展相對成熟和穩定,鴻蒙OS作為后來者兼容一個成熟的開發體系會節省很多推廣和開發成本。但在實際開發中,代碼層面仍然有很多細節上的差異,會給初次開發人員造成困擾。

本寶典旨在匯總實際開發中第三方件接入時的代碼差異,以期幫助開發人員更好的進行開發作業,由于目前接觸的開發類型有限,所匯總的內容多少會有疏漏,后期我們會進一步完善和補全。

歡迎關注我們以及我們的專欄,方便您及時獲得相關內容的更新。

消息&多線程

1.設置線程級別

安卓:

  1. android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_XXXXX); 

鴻蒙:

  1. ProcessManager.setThreadPriority(Thread.xxx); 

2.判斷是否是主線程

安卓:

  1. Looper.getMainLooper().getThread() == Thread.currentThread() 

鴻蒙:

  1. EventRunner.getMainEventRunner().isCurrentRunnerThread(); 

3.取消任務操作

安卓:

  1. task.cancel(true); 

鴻蒙:

  1. task.revoke(); 

布局&組件

1.展示一段時間的提示信息彈框

安卓:

  1. Toast makeText(Context context,String msg,int duration).show(); 

鴻蒙:

  1. new ToastDialog(Context context).setText(String msg).show(); 

2.給控件設置它的左中右上的圖片

安卓

1.代碼中:

  1. Drawable dwLeft = getResources().getDrawable(R.mipmap.ic_launcher); 
  2. dwLeft.setBounds(0, 0, dwLeft.getMinimumWidth(), dwLeft.getMinimumHeight()); 
  3. View.setCompoundDrawables(dwLeft, nullnullnull); 

 2.布局中:

  1. android:drawableLeft=“@mipmap/ic_launcher” 
  2. android:drawableTop=“@mipmap/ic_launcher” 
  3. android:drawableRight=“@mipmap/ic_launcher” 
  4. android:drawableBottom=“@mipmap/ic_launcher” 

 鴻蒙:

1.代碼中:

  1. Resource resource = context.getResourceManager().getResource(ResourceTable.Media_select); 
  2. PixelMapElement element = new PixelMapElement(resource); 
  3. companent.setAroundElements(element,null,null,null); 

 2.布局中:

  1. ohos:element_left=“media:icon" ohos:element_right="media:icon"ohos:element  
  2. ​    
  3.  ight="media:icon” 
  4. ohos:element_top=“media:icon" ohos:element_bottom="media:icon"ohos:element  
  5. ​    
  6.  ottom="media:icon” 

 3.設置控件的多態化

安卓:

1.在布局中給控件設置:android:background=“@drawable/bt_login”

2.在xml中實現bt_login

  1. <?xml version=“1.0” encoding=“utf-8”?> 
  2. <selector xmlns:android=“http://schemas.android.com/apk/res/android”> 
  3. <!-- 控件點擊狀態 --> 
  4. <item android:drawable=“@drawable/button_down” android:state_pressed=“true”></item> 
  5. <!-- 控件選中狀態 --> 
  6. <item android:drawable=“@drawable/button_down” android:state_checked=“true”></item> 
  7.  
  8. </selector> 

 鴻蒙:

  1. Resource selectResource = context.getResourceManager().getResource(ResourceTable.Media_select); 
  2. Resource emptyResource = context.getResourceManager().getResource(ResourceTable.Media_unselect); 
  3. PixelMapElement selectElement = new PixelMapElement(selectResource); 
  4. PixelMapElement emptyElement = new PixelMapElement(emptyResource); 
  5. StateElement checkElement = new StateElement(); 
  6. checkElement.addState(new int[]{ComponentState.COMPONENT_STATE_SELECTED}, selectElement); 
  7. checkElement.addState(new int[]{ComponentState.COMPONENT_STATE_EMPTY}, emptyElement); 
  8. component.setButtonElement(null); 
  9. component.setAroundElements(checkElement,null,null,null); 
  10. component.setSelected(true); 

 4.scrollView滾動

安卓:

  1. <ScrollView 
  2. android:layout_width=“match_parent” 
  3. android:layout_height=“match_parent”> 
  4. <LinearLayout 
  5. android:layout_width=“match_parent” 
  6. android:layout_height=“match_parent” 
  7. android:orientation=“vertical”> 
  8. </LinearLayout> 
  9. </ScrollView> 

 鴻蒙:

  1. <ScrollView 
  2. ohos:height=“match_content” 
  3. ohos:width=“match_parent” 
  4. <DirectionalLayout 
  5. ohos:height=“match_content” 
  6. ohos:width=“match_content” 
  7. ohos:orientation=“vertical”> 
  8. </DirectionalLayout> 
  9. </ScrollView> 

5.組件隱藏

安卓:

  1. 不可見: android:visibility=“invisible”; Java代碼:view.setVisibility(View.INVISIBLE); 隱藏: android:visibility=“gone”; Java代碼:view.setVisibility(View.GONE); 

鴻蒙:

  1. ohos:visibility=“hide”;comp.setVisibility(HIDE);ohos:visibility=“invisible”;comp.setVisibility(INVISIBLE) 

6.線性布局

安卓:

  1. LinearLayout 

鴻蒙:

  1. DirectionalLayout 

7.相對布局

安卓:

  1. RelativeLayout 

鴻蒙:

  1. DependentLayout 

8.幀布局

安卓:

  1. FrameLayout 

鴻蒙:

  1. StackLayout 

9.選項卡

安卓:

  1. TabLayout 

鴻蒙:

  1. TabList和Tab 

10.像素單位

安卓:

  1. dp 

鴻蒙:

  1. vp 

11.控件的對齊方式

安卓:

  1. Gravity.CENTER 

鴻蒙:

  1. LayoutAlignment.CENTER 

12.布局名稱及用法

安卓:

  1. RelativeLayout相對布局LinearLayout線性布局 

鴻蒙:

  1. DependentLayout相對布局 DirectionalLayout線性布局 

13.自定義布局

安卓:

  1. View inflate = 
  2. inflate(getContext(), R.layout.reg_view, this); 

 鴻蒙:

  1. component = LayoutScatter.getInstance(context).parse(com.istone.videocache.ResourceTable.Layout_ability_player,layout,false); 
  2. layout.addComponent(component, 0); 

 14.疊加布局,層級疊加

安卓:

  1. FrameLayout 

鴻蒙:

  1. StackLayout 

想了解更多內容,請訪問:

51CTO和華為官方合作共建的鴻蒙技術社區

https://harmonyos.51cto.com

 

責任編輯:jianghua 來源: 鴻蒙社區
相關推薦

2021-03-03 14:17:40

鴻蒙HarmonyOS應用開發

2019-04-10 11:06:54

前端HTMLCSS

2009-06-09 14:40:01

Javascript表單驗證

2009-06-11 15:25:39

Java隨機數

2009-06-12 10:34:40

Java Date

2025-01-22 08:01:53

2025-04-24 00:10:00

RAGAI人工智能

2013-07-08 15:45:04

Python

2009-06-12 10:08:05

StaticJava

2013-04-08 15:42:38

Backbone.js入門

2018-11-15 14:52:15

Spark數據機器學習

2013-09-24 10:07:19

Ruby項目

2011-08-03 10:12:38

2009-06-15 13:32:18

Java applet插件

2020-10-11 23:45:55

Python解釋器

2020-10-10 14:36:10

Python

2013-11-14 16:18:05

AndroidAudioAudioTrack

2018-12-19 09:03:04

物聯網供應鏈物聯網應用

2009-07-14 13:49:28

Swing組件AWT

2020-10-12 00:41:52

Python變量
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 精品久久久久久久人人人人传媒 | 亚洲黄色一区二区三区 | 黑人精品欧美一区二区蜜桃 | 成人国产精品免费观看 | 婷婷在线免费 | 麻豆一区二区三区 | 精品在线播放 | 亚洲欧美中文字幕在线观看 | 国产精品欧美日韩 | 一区二区三区四区电影 | 午夜视频在线播放 | 国内精品久久久久 | 久久99国产精一区二区三区 | 欧美成人精品在线 | 午夜精品一区二区三区在线视频 | 欧美日韩国产免费 | 一区二区三区电影在线观看 | 91一区二区三区 | 99国产视频 | 久久久久久久国产 | 国产成人综合在线 | 99re视频这里只有精品 | 久久精品日产第一区二区三区 | 91久久精品一区二区二区 | av日日操 | www.久久艹 | 久久青| 99精品一区二区 | 国产午夜久久 | 国产男女视频 | 欧美国产视频 | 91久久夜色精品国产网站 | 伊人婷婷 | 一区二区精品视频 | 国产视频第一页 | 欧美亚洲综合久久 | 国产91中文 | 国产精品久久久久久久7电影 | 中文一区 | a级黄色网| 盗摄精品av一区二区三区 |