成人免费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-12 10:34:40

Java Date

2009-06-11 15:25:39

Java隨機數

2013-07-08 15:45:04

Python

2025-01-22 08:01:53

2025-04-24 00:10:00

RAGAI人工智能

2013-04-08 15:42:38

Backbone.js入門

2009-06-12 10:08:05

StaticJava

2013-09-24 10:07:19

Ruby項目

2011-08-03 10:12:38

2009-06-15 13:32:18

Java applet插件

2018-11-15 14:52:15

Spark數據機器學習

2020-10-11 23:45:55

Python解釋器

2013-11-14 16:18:05

AndroidAudioAudioTrack

2020-10-10 14:36:10

Python

2018-12-19 09:03:04

物聯網供應鏈物聯網應用

2010-03-11 11:29:51

喬布斯

2009-07-14 13:49:28

Swing組件AWT
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产高清久久久 | 91精品国产综合久久久久久首页 | 久草99 | 在线观看成人精品 | 亚洲午夜精品久久久久久app | 天天天天天操 | av一区二区三区四区 | 欧美日韩精品一区二区三区视频 | 国产精品成人在线播放 | 国产第1页 | 久久一区二区三区四区 | 日韩综合色| 欧美国产一区二区三区 | 一道本在线 | www久| 亚洲狠狠丁香婷婷综合久久久 | 国产中文字幕网 | 国产一区二 | 天堂av中文在线 | 日韩中文字幕区 | 国产成人a亚洲精品 | 91精品国产91久久久久久最新 | 国产精品免费一区二区三区 | 欧美a级成人淫片免费看 | 亚洲精品一区二区三区蜜桃久 | 欧美影院 | 99热在线观看精品 | wwwxxx国产 | 欧美无乱码久久久免费午夜一区 | 欧美a区| 国产午夜精品一区二区三区四区 | 日韩视频中文字幕 | www四虎影视 | 亚洲一区二区视频在线播放 | 国产精品久久影院 | 国产色网| 北条麻妃国产九九九精品小说 | 成人久久网 | 精品久久国产 | 日日操夜夜操天天操 | 人人草人人干 |