要实现这样的效果,

<TextView
android:id="@+id/tv_card_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/view"
android:layout_alignRight="@+id/view"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dimen_13pt"
android:background="@drawable/setcard_bg"
android:paddingBottom="@dimen/dimen_8pt"
android:paddingLeft="@dimen/dimen_12pt"
android:paddingRight="@dimen/dimen_12pt"
android:paddingTop="@dimen/dimen_8pt"
android:textColor="@color/accent"
android:textSize="@dimen/dimen_15pt"
tools:text="充值卡" />
他外边的框写在drawable中
setcard_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/transparent"/>//矩形填充的颜色为透明色

<stroke android:width="1dip" android:color="@color/accent" />//矩形线的颜色
<corners android:topLeftRadius="10dp"
android:topRightRadius="10dp"
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"/>//圆角的弧度
</shape>