需求:
實現(xiàn)代碼:
文件地址:res/drawable-hdpi/circle_shape.xml
<shape android:shape="oval">
<stroke android:width="2dp" android:color="#f832"/>
<size android:height="10dp" android:width="10dp" />
</shape>
(上面的代碼為一個橢圓形体啰,如果你的View是寬高相等稻扬,就是圓形了卦方,如下代碼)
布局文件:
<TextView
android:layout_width="10dp"
android:layout_height="10dp"
android:gravity="center"
android:background="@drawable/circle_shape"
/>
拓展:
如果你想要設(shè)置設(shè)置圓形,一定要在引用的地方寬高寫死泰佳,寬高也要相等盼砍,在shape文件寫了,也必須在引用里面寫死寬高逝她,才是圓形浇坐,不然很有可能是橢圓。
stroke:用筆畫黔宛,也可以翻譯成輪廓吧近刘。可以畫空心的臀晃。像Paint.Style.STROKE
solide:固體的跌宛,實體的。 也就是實心的积仗。像Paint.Style.FILL