Android Drawable 직접 만들어보기

timothy jeong·2021년 11월 1일
0

Android with Kotlin

목록 보기
6/69

res/drawable 에서 new -> Drawable Resource File
그리고 원하는 이름으로 파일을 작성 아래의 예시 파일 이름은 round_button 으로 생성함.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <solid android:color="@color/round_button_color"></solid>
    <corners
        android:bottomLeftRadius="30dp"
        android:bottomRightRadius="30dp"
        android:topLeftRadius="30dp"
        android:topRightRadius="30dp">
    </corners>
</shape>

요런게 생긴다.

이걸 layout 에 적용할 수 있는데, background 에 적용하면

   <Button
            android:id="@+id/startButton"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="@string/start"
            android:background="@drawable/round_button"
            android:textColor="@color/white"
            android:textStyle="bold"/>

이런 버튼이 만들어진다!

profile
개발자

0개의 댓글