【问题标题】:I would like to create a textView surrounded rounded circle the diagram as shown below我想创建一个textView包围的圆角图如下图
【发布时间】:2017-01-23 16:55:03
【问题描述】:

我想创建一个textView包围的圆形图如下图:

图片链接:-https://i.stack.imgur.com/E0cMB.png

谁能告诉我怎么做?

【问题讨论】:

  • 以drawable为背景
  • 使用 xml 创建视图的最佳方法。
  • Champandorid 我必须在该图像中将文本设置为 textview。所以这就是为什么我没有将其视为可绘制

标签: android textview rounded-corners


【解决方案1】:

查看如何实现上述图像要求。 你的布局数据应该是这样的:

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#004473">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:layout_margin="5dp"
                android:background="@drawable/linear_layout_corner_shape"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:gravity="center"
                    android:text="01"
                    android:background="@drawable/textview_circle_shape"
                    android:textSize="20sp"
                    android:textColor="#000000"/>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:paddingLeft="15dp"
                    android:text="Lorum Ipusum"
                    android:textSize="20sp"
                    android:textColor="#FFFFFF"/>

            </LinearLayout>

        </LinearLayout>

可绘制文件数据:

linear_layout_corner_shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

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

<stroke
    android:width="2dp"
    android:color="#FFFFFF"></stroke>

<corners android:radius="30dp"></corners>

textview_circle_shape.xml

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-14
    • 2020-06-26
    • 2011-06-08
    相关资源
    最近更新 更多