24. DirectionalLayout - 拨号界面练习

样式:

代码: 

text_empty.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:shape="rectangle">

    <stroke
        ohos:color="#000000"
        ohos:width="3vp"/>

    <corners

        ohos:radius="15vp"/>

</shape>

 button_empty.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:shape="oval">

    <stroke
        ohos:color="#000000"
        ohos:width="3vp"
        />

</shape>

button_press.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:shape="oval">

    <stroke
        ohos:color="#000000"
        ohos:width="3vp"
        />

    <stroke ohos:color="#00FF00"/>

</shape>

 button_state.xml

<?xml version="1.0" encoding="utf-8"?>
<state-container
    xmlns:ohos="http://schemas.huawei.com/res/ohos">

    <item ohos:state="component_state_pressed" ohos:element="$graphic:button_press"/>
    <item ohos:state="component_state_empty" ohos:element="$graphic:button_empty"/>

</state-container>

ability_main.xml

<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    ohos:orientation="vertical">

    <Text
        ohos:height="50vp"
        ohos:width="200vp"
        ohos:background_element="$graphic:text_empty"
        ohos:layout_alignment="horizontal_center"
        ohos:text_size="20fp"
        ohos:top_margin="30vp"/>

    <DirectionalLayout
        ohos:height="match_content"
        ohos:width="match_parent"
        ohos:alignment="horizontal_center"
        ohos:orientation="horizontal"
        ohos:top_margin="30vp">

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="1"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="2"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="3"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>
    </DirectionalLayout>

    <DirectionalLayout
        ohos:height="match_content"
        ohos:width="match_parent"
        ohos:alignment="horizontal_center"
        ohos:orientation="horizontal"
        ohos:top_margin="10vp">

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="4"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="5"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="6"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>
    </DirectionalLayout>

    <DirectionalLayout
        ohos:height="match_content"
        ohos:width="match_parent"
        ohos:alignment="horizontal_center"
        ohos:orientation="horizontal"
        ohos:top_margin="10vp">

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="7"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="8"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="9"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>
    </DirectionalLayout>

    <DirectionalLayout
        ohos:height="match_content"
        ohos:width="match_parent"
        ohos:alignment="horizontal_center"
        ohos:orientation="horizontal"
        ohos:top_margin="10vp">

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="#"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="0"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>

        <Button
            ohos:height="70vp"
            ohos:width="70vp"
            ohos:background_element="$graphic:button_state"
            ohos:text="*"
            ohos:text_alignment="center"
            ohos:text_color="#000000"
            ohos:text_size="35fp"/>
    </DirectionalLayout>

    <Button
        ohos:height="50vp"
        ohos:width="200vp"
        ohos:text="CALL"
        ohos:text_size="35fp"
        ohos:text_color="#000000"
        ohos:text_alignment="center"
        ohos:top_margin="50vp"
        ohos:background_element="$graphic:text_empty"
        ohos:layout_alignment="horizontal_center"/>

</DirectionalLayout>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值