最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

鴻蒙開發(fā)之Button按鈕類型及如何通過代碼設(shè)置(HarmonyOS鴻蒙開發(fā)基礎(chǔ)知識)

 更新時間:2020年09月14日 11:34:13   作者:知識大胖  
這篇文章主要介紹了鴻蒙開發(fā)之Button按鈕類型及如何通過代碼設(shè)置(HarmonyOS鴻蒙開發(fā)基礎(chǔ)知識),本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

AbilitySlice 是什么 (HarmonyOS鴻蒙開發(fā)基礎(chǔ)知識)

AbilitySlice 是什么
AbilitySlice主要用于承載Ability的具體邏輯實現(xiàn)和界面UI,是應(yīng)用顯示、運行和跳轉(zhuǎn)的最小單元。AbilitySlice通過setUIContent()為界面設(shè)置布局

本文重點給大家介紹鴻蒙開發(fā)之Button按鈕類型及如何通過代碼設(shè)置(HarmonyOS鴻蒙開發(fā)基礎(chǔ)知識),具體內(nèi)容如下所示:

Button類型分類

按照按鈕的形狀,按鈕可以分為:

  • 普通按鈕
  • 橢圓按鈕
  • 膠囊按鈕
  • 圓形按鈕
  • 其它

Button類型效果和代碼

普通按鈕

普通按鈕和其他按鈕的區(qū)別在于不需要設(shè)置任何形狀,只設(shè)置文本和背景顏色即可,例如:

image.png

<Button
 ohos:width="150vp"
 ohos:height="50vp"
 ohos:text_size="27fp"
 ohos:text="button"
 ohos:background_element="$graphic:color_blue_element"
 ohos:left_margin="15vp"
 ohos:bottom_margin="15vp"
 ohos:right_padding="8vp"
 ohos:left_padding="8vp"
/>

橢圓按鈕

橢圓按鈕是通過設(shè)置background_element的來實現(xiàn)的,background_element的shape設(shè)置為橢圓(oval),例如:

image.png

<Button
 ohos:width="150vp"
 ohos:height="50vp"
 ohos:text_size="27fp"
 ohos:text="button"
 ohos:background_element="$graphic:oval_button_element"
 ohos:left_margin="15vp"
 ohos:bottom_margin="15vp"
 ohos:right_padding="8vp"
 ohos:left_padding="8vp"
 ohos:element_left="$graphic:ic_btn_reload"
/>

膠囊按鈕

膠囊按鈕是一種常見的按鈕,設(shè)置按鈕背景時將背景設(shè)置為矩形形狀,并且設(shè)置ShapeElement的radius的半徑,例如:

image.png

<Button
 ohos:id="$+id:button"
 ohos:width="match_content"
 ohos:height="match_content"
 ohos:text_size="27fp"
 ohos:text="button"
 ohos:background_element="$graphic:capsule_button_element"
 ohos:left_margin="15vp"
 ohos:bottom_margin="15vp"
 ohos:right_padding="15vp"
 ohos:left_padding="15vp"
/>

圓形按鈕

圓形按鈕和橢圓按鈕的區(qū)別在于組件本身的寬度和高度需要相同,例如:

image.png

<Button
 ohos:id="$+id:button4"
 ohos:width="50vp"
 ohos:height="50vp"
 ohos:text_size="27fp"
 ohos:background_element="$graphic:circle_button_element"
 ohos:text="+"
 ohos:left_margin="15vp"
 ohos:bottom_margin="15vp"
 ohos:right_padding="15vp"
 ohos:left_padding="15vp"
/>

場景示例

利用圓形按鈕,膠囊按鈕,文本組件可以繪制出如下?lián)芴柋P的UI界面。

image.png

<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
 xmlns:ohos="http://schemas.huawei.com/res/ohos"
 ohos:width="match_parent"
 ohos:height="match_parent"
 ohos:background_element="$graphic:color_light_gray_element"
 ohos:orientation="vertical">
 <Text
 ohos:width="match_content"
 ohos:height="match_content"
 ohos:text_size="20fp"
 ohos:text="0123456789"
 ohos:background_element="$graphic:green_text_element"
 ohos:text_alignment="center"
 ohos:layout_alignment="horizontal_center"
 />
 <DirectionalLayout
 ohos:width="match_parent"
 ohos:height="match_content"
 ohos:alignment="horizontal_center"
 ohos:orientation="horizontal"
 ohos:top_margin="5vp"
 ohos:bottom_margin="5vp">
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="1"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="2"
  ohos:left_margin="5vp"
  ohos:right_margin="5vp"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="3"
  ohos:text_alignment="center"
 />
 </DirectionalLayout>
 <DirectionalLayout
 ohos:width="match_parent"
 ohos:height="match_content"
 ohos:alignment="horizontal_center"
 ohos:orientation="horizontal"
 ohos:bottom_margin="5vp">
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="4"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:left_margin="5vp"
  ohos:right_margin="5vp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="5"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="6"
  ohos:text_alignment="center"
 />
 </DirectionalLayout>
 <DirectionalLayout
 ohos:width="match_parent"
 ohos:height="match_content"
 ohos:alignment="horizontal_center"
 ohos:orientation="horizontal"
 ohos:bottom_margin="5vp">
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="7"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:left_margin="5vp"
  ohos:right_margin="5vp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="8"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="9"
  ohos:text_alignment="center"
 />
 </DirectionalLayout>
 <DirectionalLayout
 ohos:width="match_parent"
 ohos:height="match_content"
 ohos:alignment="horizontal_center"
 ohos:orientation="horizontal"
 ohos:bottom_margin="5vp">
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="*"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:left_margin="5vp"
  ohos:right_margin="5vp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="0"
  ohos:text_alignment="center"
 />
 <Button
  ohos:width="40vp"
  ohos:height="40vp"
  ohos:text_size="15fp"
  ohos:background_element="$graphic:green_circle_button_element"
  ohos:text="#"
  ohos:text_alignment="center"
 />
 </DirectionalLayout>
 <Button
 ohos:width="match_content"
 ohos:height="match_content"
 ohos:text_size="15fp"
 ohos:text="CALL"
 ohos:background_element="$graphic:green_capsule_button_element"
 ohos:bottom_margin="5vp"
 ohos:text_alignment="center"
 ohos:layout_alignment="horizontal_center"
 ohos:left_padding="10vp"
 ohos:right_padding="10vp"
 ohos:top_padding="2vp"
 ohos:bottom_padding="2vp"
 />
</DirectionalLayout>

總結(jié)

到此這篇關(guān)于鴻蒙開發(fā)之Button按鈕類型及如何通過代碼設(shè)置(HarmonyOS鴻蒙開發(fā)基礎(chǔ)知識)的文章就介紹到這了,更多相關(guān)鴻蒙開發(fā)Button按鈕類型內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 鴻蒙OS運行第一個“hello world”

    鴻蒙OS運行第一個“hello world”

    這篇文章主要介紹了鴻蒙OS運行第一個“hello world”,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 詳解HarmonyOS簡介

    詳解HarmonyOS簡介

    HarmonyOS是一款“面向未來”、面向全場景(移動辦公、運動健康、社交通信、媒體娛樂等)的分布式操作系統(tǒng)。本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-09-09
  • 詳解DevEco Studio項目構(gòu)建講解、編寫頁面、布局介紹、頁面跳轉(zhuǎn)

    詳解DevEco Studio項目構(gòu)建講解、編寫頁面、布局介紹、頁面跳轉(zhuǎn)

    這篇文章主要介紹了詳解DevEco Studio項目構(gòu)建講解、編寫頁面、布局介紹、頁面跳轉(zhuǎn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • BIOS設(shè)置圖解教程 Award Bios最新(轉(zhuǎn))

    BIOS設(shè)置圖解教程 Award Bios最新(轉(zhuǎn))

    我們來介紹一下Award Bios的設(shè)置,其實Award Bios和AMI Bios里面有很多東西是相同的,可以說基本上是一樣的,雖然有些名字叫法不同,但是實際作用是一樣的
    2007-01-01
  • win10設(shè)定計劃任務(wù)時提示所指定的賬戶名稱無效問題解析

    win10設(shè)定計劃任務(wù)時提示所指定的賬戶名稱無效問題解析

    這篇文章主要介紹了win10設(shè)定計劃任務(wù)時提示所指定的賬戶名稱無效問題解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-09-09
  • 打造個性_安全的電腦系統(tǒng)圖文教程2

    打造個性_安全的電腦系統(tǒng)圖文教程2

    個性_安全的電腦系統(tǒng)圖文教程
    2008-05-05
  • 鴻蒙HarmonyOS剪切板的實現(xiàn)

    鴻蒙HarmonyOS剪切板的實現(xiàn)

    這篇文章主要介紹了鴻蒙HarmonyOS剪切板的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 如何讓W(xué)indowsForm縮小到系統(tǒng)匣過程詳解

    如何讓W(xué)indowsForm縮小到系統(tǒng)匣過程詳解

    這篇文章主要介紹了讓W(xué)indowsForm縮小到系統(tǒng)匣過程詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-09-09
  • 深度操作系統(tǒng) deepin 15.11安裝 QGIS 3.4

    深度操作系統(tǒng) deepin 15.11安裝 QGIS 3.4

    深度操作系統(tǒng)是基于Linux內(nèi)核,以桌面應(yīng)用為主的開源 GNU/Linux 操作系統(tǒng),支持筆記本、臺式機和一體機,這篇文章給大家介紹deepin 15.11安裝 QGIS 3.4的方法,需要的朋友參考下吧
    2020-02-02
  • MAC找回系統(tǒng)賬號密碼常用方法

    MAC找回系統(tǒng)賬號密碼常用方法

    這篇文章主要介紹了MAC找回系統(tǒng)賬號密碼常用方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-10-10

最新評論

和平区| 黎川县| 平乡县| 忻州市| 新河县| 成安县| 南汇区| 乌拉特中旗| 丰原市| 航空| 霍城县| 松阳县| 辽阳市| 壤塘县| 蒙阴县| 胶州市| 朝阳区| 凤翔县| 襄樊市| 庆云县| 平陆县| 大埔县| 阿巴嘎旗| 白城市| 边坝县| 深泽县| 西平县| 长宁县| SHOW| 札达县| 蒙城县| 麦盖提县| 丁青县| 土默特左旗| 福海县| 东安县| 长乐市| 普洱| 福贡县| 邯郸县| 石棉县|