自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

HarmonyOS APP組件分享(一)

系統(tǒng) OpenHarmony
文章由鴻蒙社區(qū)產(chǎn)出,想要了解更多內(nèi)容請前往:51CTO和華為官方戰(zhàn)略合作共建的鴻蒙技術(shù)社區(qū)https://harmonyos.51cto.com

想了解更多內(nèi)容,請?jiān)L問:

51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos.51cto.com

HarmonyOSAPP-Image體驗(yàn)與分享

一、各項(xiàng)效果展示

二、體驗(yàn)操作過程

這里敲的是一個image的案例

實(shí)現(xiàn)我們得導(dǎo)入一張圖片,把這張圖片導(dǎo)入到“entry > src > main > resources > base > media”中,如下圖所示:

這里我們可以通過在布局里面使用Image標(biāo)簽進(jìn)行圖片的插入和樣式的設(shè)置。

這里我們可以通過image_src導(dǎo)入想要的圖片,這里要注意圖片的規(guī)格和大小。

我們也可以通過alpha色澤圖片的透明性

我們也可以通過scale_x,scale_y設(shè)置圖片的縮放系數(shù)

我們這里也可以通過設(shè)置clip_alignment控制裁剪的位置

三、完整代碼下載

https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_image_component

HarmonyOSAPP-TextField體驗(yàn)與分享

TextField提供了一種文本輸入框。下面會通過一個案例給大家展示一下這個組件。

顯示效果:

代碼如下:

  1. Slice文件中 
  2.  
  3. package com.example.jltftiyan3.slice; 
  4.  
  5. import com.example.jltftiyan3.ResourceTable; 
  6. import ohos.aafwk.ability.AbilitySlice; 
  7. import ohos.aafwk.content.Intent; 
  8. import ohos.agp.components.Button; 
  9. import ohos.agp.components.Component; 
  10. import ohos.agp.components.Text; 
  11. import ohos.agp.components.TextField; 
  12. import ohos.agp.components.element.ShapeElement; 
  13.  
  14. public class MainAbilitySlice extends AbilitySlice { 
  15.     @Override 
  16.     public void onStart(Intent intent) { 
  17.         super.onStart(intent); 
  18.         super.setUIContent(ResourceTable.Layout_ability_main); 
  19.  
  20.     } 
  21.  
  22.     @Override 
  23.     public void onActive() { 
  24.         super.onActive(); 
  25.     } 
  26.  
  27.     @Override 
  28.     public void onForeground(Intent intent) { 
  29.         super.onForeground(intent); 
  30.     } 

布局中的代碼:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <DirectionalLayout 
  3.     xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  4.     ohos:width="match_parent" 
  5.     ohos:height="match_parent" 
  6.     ohos:background_element="#FFC9C3C3" 
  7.     ohos:orientation="vertical"
  8.  
  9.     <StackLayout 
  10.         ohos:top_margin="60vp" 
  11.         ohos:width="match_parent" 
  12.         ohos:height="match_content" 
  13.         ohos:layout_alignment="center"
  14.         <TextField 
  15.             ohos:id="$+id:name_textField" 
  16.             ohos:width="1000px" 
  17.             ohos:height="match_content" 
  18.             ohos:multiple_lines="false" 
  19.             ohos:left_padding="24vp" 
  20.             ohos:right_padding="24vp" 
  21.             ohos:top_padding="8vp" 
  22.             ohos:bottom_padding="8vp" 
  23.             ohos:min_height="44vp" 
  24.             ohos:text_size="18fp" 
  25.             ohos:layout_alignment="center" 
  26.             ohos:text_alignment="center_vertical" 
  27.             ohos:background_element="$graphic:jltfbackground_text_field" 
  28.             ohos:hint="請輸入賬號" /> 
  29.  
  30.     </StackLayout> 
  31.  
  32.     <TextField 
  33.         ohos:top_margin="40vp" 
  34.         ohos:id="$+id:password_text_field" 
  35.         ohos:width="1000px" 
  36.         ohos:height="match_content" 
  37.         ohos:multiple_lines="false" 
  38.         ohos:left_padding="24vp" 
  39.         ohos:right_padding="24vp" 
  40.         ohos:top_padding="8vp" 
  41.         ohos:bottom_padding="8vp" 
  42.         ohos:min_height="44vp" 
  43.         ohos:text_size="18fp" 
  44.         ohos:layout_alignment="center" 
  45.         ohos:text_alignment="center_vertical" 
  46.         ohos:background_element="$graphic:jltfbackground_text_field" 
  47.         ohos:hint="請輸入密碼" /> 
  48.  
  49.     <Button 
  50.         ohos:top_margin="40vp" 
  51.         ohos:id="$+id:ensure_button" 
  52.         ohos:width="120vp" 
  53.         ohos:height="35vp" 
  54.         ohos:background_element="$graphic:jltfbackground_btn" 
  55.         ohos:text="Log in" 
  56.         ohos:text_size="20fp" 
  57.         ohos:layout_alignment="horizontal_center"/> 
  58.  
  59. </DirectionalLayout> 

完整代碼包地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_TextField_component

想了解更多內(nèi)容,請?jiān)L問:

51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos.51cto.com

 

責(zé)任編輯:jianghua 來源: 鴻蒙社區(qū)
相關(guān)推薦

2021-03-30 09:45:07

鴻蒙HarmonyOS應(yīng)用開發(fā)

2021-03-31 15:49:34

鴻蒙HarmonyOS應(yīng)用

2021-03-26 09:35:35

鴻蒙HarmonyOS應(yīng)用開發(fā)

2021-03-18 09:36:02

鴻蒙HarmonyOS應(yīng)用

2012-04-28 21:25:58

APP

2021-03-22 09:48:32

鴻蒙HarmonyOS應(yīng)用開發(fā)

2012-12-04 09:37:29

視頻分享App

2010-07-28 12:41:18

Flex組件

2021-01-11 11:36:23

鴻蒙HarmonyOSApp開發(fā)

2022-02-10 15:14:50

HarmonyOS操作系統(tǒng)鴻蒙

2013-12-16 09:36:08

App項(xiàng)目

2021-01-14 09:50:26

鴻蒙HarmonyOSAPP

2015-03-24 20:07:18

APP推廣APP運(yùn)營

2013-01-10 12:57:23

產(chǎn)品經(jīng)理App產(chǎn)品設(shè)計(jì)

2013-04-28 13:52:05

app

2019-07-26 13:44:45

2011-12-27 15:21:16

趕集團(tuán)購Web App

2016-03-18 13:40:24

androidPad騰訊

2011-11-08 11:03:26

App Store蘋果應(yīng)用推廣

2022-07-29 11:03:47

VueUni-app
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號