圆形的textview

圆形textview
最近由于项目需求,在UI图中使用到圆形的textview,所以自己就做了下,其实挺简单的,仔细想一下,平常我们经常用到的都是矩形的,所在在此我们只需更换一下textview的背景就可以了,自己去画一个圆形的,通过shape,效果如下:
圆形textview
,具体代码如下:
shape_round_textview.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">

    <solid android:color="@color/white" />

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

</shape>

现在咱们组合一下另一个textview,效果如下:
这里写图片描述

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center">

            <RelativeLayout
                android:id="@+id/relativeLayout4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/id_tv_name4"
                    android:layout_width="70dp"
                    android:layout_height="70dp"
                    android:background="@drawable/shape_round_textview"
                    android:gravity="center"
                    android:text="中小客" />

                <TextView
                    android:id="@+id/id_tv_num4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/id_tv_name4"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="4dp"
                    android:background="@drawable/shape_round_text"
                    android:text="1876"
                    android:textColor="@color/white" />
            </RelativeLayout>

版权声明:本文为speverriver原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。