Android开发-绘制带数字的圆点

这里写图片描述

想要完成如图所示的图片的中,带数字的圆点1,2,3的绘制。
首先在drawable文件加下边创建一个xml文件

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="oval"
       android:useLevel="false" >

    <solid android:color="#FFB90F" />

    <padding
        android:bottom="1dp"
        android:left="8dp"
        android:right="8dp"
        android:top="1dp" />

    <size
        android:height="15dp"
        android:width="25dp" />

</shape>

把上边的代码放在布局文件中,给TextView设置成background即可,圆点中显示的数字就是
android:text=”1”
text属性中设置的值。

接下来,自己进行界面的布局和调整,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:orientation="vertical">



    <RelativeLayout
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:gravity="center"
            android:id="@+id/first"
            android:layout_width="@dimen/space_35"
            android:layout_height="@dimen/space_35"
            android:layout_marginTop="5dp"
            android:background="@drawable/green_drak_point"
            android:text="1"
            android:textColor="@color/white"
            android:textSize="20sp" />

        <View
            android:id="@+id/view1"
            android:layout_toRightOf="@+id/first"
            android:layout_centerVertical="true"
            android:layout_marginLeft="@dimen/space_8"
            android:layout_marginRight="@dimen/space_8"
            android:layout_width="@dimen/space_70"
            android:layout_height="@dimen/space_3"
            android:background="@color/green_light" />
        <TextView
            android:id="@+id/second"
            android:gravity="center"
            android:layout_toRightOf="@+id/view1"
            android:layout_width="@dimen/space_35"
            android:layout_height="@dimen/space_35"
            android:layout_marginTop="5dp"
            android:background="@drawable/green_light_point"
            android:text="2"
            android:textColor="@color/white"
            android:textSize="20sp" />
        <View
            android:id="@+id/view2"
            android:layout_marginLeft="@dimen/space_8"
            android:layout_marginRight="@dimen/space_8"
            android:layout_toRightOf="@+id/second"
            android:layout_centerVertical="true"
            android:layout_width="@dimen/space_70"
            android:layout_height="@dimen/space_3"
            android:background="@color/green_light" />

        <TextView
            android:layout_toRightOf="@+id/view2"
            android:gravity="center"
            android:layout_width="@dimen/space_35"
            android:layout_height="@dimen/space_35"
            android:layout_marginTop="5dp"
            android:background="@drawable/green_light_point"
            android:text="3"
            android:textColor="@color/white"
            android:textSize="20sp" />

    </RelativeLayout>


    <LinearLayout
        android:layout_marginTop="@dimen/space_10"
        android:layout_marginLeft="@dimen/space_30"
        android:layout_marginRight="@dimen/space_30"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal" >
        <TextView
            android:gravity="center"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="用户注册"
            android:textColor="@color/green_dark"
            android:textSize="@dimen/text_size_16" />

        <TextView
            android:gravity="center"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_marginLeft="@dimen/space_40"
            android:layout_marginRight="@dimen/space_40"
            android:layout_height="wrap_content"
            android:text="绑定银行卡"
            android:textColor="@color/green_light"
            android:textSize="@dimen/text_size_16"
            />
        <TextView
            android:gravity="center"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="完成"
            android:textColor="@color/green_light"
            android:textSize="@dimen/text_size_16" />
    </LinearLayout>


</LinearLayout>

其中一些属性值自己可修改使用,即可有图上图的效果。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值