반원뷰를 그려보기

나고수·2022년 6월 26일
0

Android

목록 보기
89/109
post-thumbnail

layout_constraintCircle 속성을 이용해 반원뷰를 그려봅시다.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#00ffffff">

    <!--기준이 되는 imageView. root view 중앙에 위치시킵니다.-->
    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/oval"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#00ffffff" />

    <!--
    layout_constraintCircle: 기준이 되는 뷰(원의 중심 이라고 생각하면됨)
    layout_constraintCircleAngle : 원 둘레에서 뷰가배치될 각도 (시계방향을 기준으로 12시:0 / 3시:90/ 6시:180/ 9시:270)
    layout_constraintCircleRadius : 기준이 되는 뷰 에서 떨어진 거리(반지름 이라 생각하면됨)
    rotation : 뷰 자체를 회전 (layout_constraintCircleAngle과 맞추면 됨)
    tint : 색상변경-->
  
    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="280"
        android:src="@drawable/oval"
        android:tag="0"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="280"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#2edffc" />


    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="288"
        android:src="@drawable/oval"
        android:tag="5"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="288"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#2edbfa" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id10"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="296"
        android:src="@drawable/oval"
        android:tag="10"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="296"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#2fc6f7" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id15"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="304"
        android:src="@drawable/oval"
        android:tag="15"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="304"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#2bb4f4" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id20"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="312"
        android:src="@drawable/oval"
        android:tag="20"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="312"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#2ba2f1" />


    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id25"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="320"
        android:src="@drawable/oval"
        android:tag="25"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="320"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#308cee" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id30"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="328"
        android:src="@drawable/oval"
        android:tag="30"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="328"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#389aea" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id35"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="336"
        android:src="@drawable/oval"
        android:tag="35"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="336"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#4258ff" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id40"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="344"
        android:src="@drawable/oval"
        android:tag="40"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="344"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#4f42e0" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id45"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="352"
        android:src="@drawable/oval"
        android:tag="45"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="352"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#5f34d7" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id50"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/oval"
        android:tag="50"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="360"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#7333cc" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id55"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="8"
        android:src="@drawable/oval"
        android:tag="55"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="368"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#8532bf" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id60"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="16"
        android:src="@drawable/oval"
        android:tag="60"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="376"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#9731b3" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id65"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="24"
        android:src="@drawable/oval"
        android:tag="65"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="384"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#a930a7" />


    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id70"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="32"
        android:src="@drawable/oval"
        android:tag="70"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="392"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#b72e9e" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id75"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="40"
        android:src="@drawable/oval"
        android:tag="75"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="400"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#c52f96" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id80"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="48"
        android:src="@drawable/oval"
        android:tag="80"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="408"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#cf2e91" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id85"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="56"
        android:src="@drawable/oval"
        android:tag="85"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="416"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#d62e8b" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id90"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="64"
        android:src="@drawable/oval"
        android:tag="90"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="424"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#d82e8b" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id95"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="68"
        android:src="@drawable/oval"
        android:tag="95"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="432"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#dc2e89" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/id100"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="72"
        android:src="@drawable/oval"
        android:tag="100"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintCircle="@id/center"
        app:layout_constraintCircleAngle="440"
        app:layout_constraintCircleRadius="130dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="#de2e89" />
</androidx.constraintlayout.widget.ConstraintLayout>
 
profile
되고싶다

0개의 댓글

관련 채용 정보