Before 2022/Android

도넛형 View 만들기

Eljoe 2019. 7. 11. 10:52

res > drawable > doughnut.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="@color/colorPrimary" />
    <stroke
        android:width="10dp"
        android:color="@color/colorAccent" />
    <corners android:radius="15pt" />
</shape>

적용할 xml

<TextView
  android:id="@+id/tv_circular"
  android:layout_width="150dp"
  android:layout_height="150dp"
  android:background="@drawable/doughnut"
  android:gravity="center"
  android:text="Doughnut"
  android:textColor="@color/colorAccent"/>