android實現控件圓角

在Android中,有一種特殊的圖形,成爲shape,在使用圖片的地方,基本上可以使用shape,他能實現圓角,邊框,漸變等功能。
1、定義圓角shape
在drawable文件夾下新建一個shape_color_primary.xml文件

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android">
    <!--角度-->
    <!--radius的值爲控件高度的一半-->
    <corners
        android:radius="15dp" />
    <!--填充色-->
    <solid
        android:color="@color/blue"/>
</shape>

2、通過控件的background屬性引入,實現控件圓角

		<Button
        android:id="@+id/r_login"
        android:text="@string/register"
        android:textColor="@color/white"
        android:layout_width="match_parent"
        android:background="@drawable/radius_fill_blue"
        android:layout_height="wrap_content"/>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章