我有一个列表视图,行模型/设计应该是如下图所示。
我的问题是,如何设计一个视图显示在第三行的图像中?我想设计一些像圆角的蓝色矩形形状,然后在图像上显示值
是textview还是imageView?请告知我如何设计这样的观点。
图片:
答案 0 :(得分:1)
您可以使用textview并在xml
下使用文本视图的背景rounded_corner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#abcdef" >
</solid>
<corners
android:radius="20dp" >
</corners>
</shape>
答案 1 :(得分:1)
您必须创建 TextView 并为其指定形状:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="@color/common_border_color" />
<solid android:color="replace with blue color" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:radius="5dp" />
</shape>
在drawable文件夹中的一个名为 rounded_corner.xml 的xml中进行此操作。
android:background="@drawable/rounded_corner"
答案 2 :(得分:0)
In your drawable create one xml file and add this code in that
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<padding
android:top="3dp"
android:left="8dp"
android:right="8dp"
android:bottom="3dp"/>
<solid android:color="#00796B" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
In your view(Button/TextView) add background, some ex code
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/delete"
android:text="Ur text"/>