底部矩形的圆形Textview

时间:2018-03-30 13:05:57

标签: android android-layout android-imageview textview android-drawable

我尝试创建一个圆形文本视图,底部有一个矩形作为参考目的,我在这里分享了示例图像并编写了我想要实现的内容

任何人都可以帮我创建以下屏幕截图,提前致谢。

Trying to create this kind of circular text-view

1 个答案:

答案 0 :(得分:4)

试试这个

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ff0"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/myTv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/ic_dot"
            android:gravity="center"
            android:padding="10dp"
            android:text="sdsjhdsd"
            android:textColor="#ff00" />

        <TextView
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/myTv"
            android:gravity="center"
            android:layout_centerHorizontal="true"
            android:background="@drawable/test"
            android:text="sdsjhdsd" />
    </RelativeLayout>
</LinearLayout>

<强>机器人:背景= “@绘制/ ic_dot”

   <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:bottomLeftRadius="100dp"
        android:bottomRightRadius="100dp"
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp" />
    <solid android:color="@color/lightWhite" />
    <size
        android:width="100dp"
        android:height="100dp" />
    <stroke
        android:width="3dp"
        android:color="#22ff00" />
</shape>

<强>机器人:背景= “@绘制/测试”

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#e60707" />

    <corners android:radius="50dp" />
</shape>

<强> RESULT

![enter image description here

相关问题