Android TextView 圓弧
效果圖:


布局代碼:
<TextView android:id="@+id/product_tag" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:singleLine="true" android:textSize="10sp" android:textColor="@color/label_orange" android:layout_marginLeft="10dp" android:background="@drawable/shape_label_orange" android:text="標簽"/>
樣式代碼:
弧度和背景主要靠background中的.xml文件實現

1、
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 實心 --> <solid android:color="@android:color/white"/> <!-- 邊框 --> <stroke android:width="0.5dp" android:color="@color/label_orange"/> <!-- 圓角 --> <corners android:radius="3dp"/> <!-- 邊距 --> <padding android:top="2dp" android:bottom="2dp" android:left="6dp" android:right="6dp"/> </shape>
2、
<?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/label_round_orange" /> <!-- 圓角 --> <corners android:radius="360dp" /> <!-- 邊距 --> <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> <!-- 大小 --> <size android:width="15dp" android:height="15dp" /> </shape>
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答