Android Studio
[Android Studio] 둥근 도형 만들기 ( Shape Drawable )
128june
2020. 7. 29. 15:11
반응형
간단하게 상하좌우가 둥근 background 이미지를 만들어보려고 합니다.
코드는 다음과 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<!-- 도형 생성 / shape 속성에서 padding / shape 설정-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<!-- 배경 색 설정 / 제가 color에 지정한 색입니다 ㅎㅎ -->
<solid android:color="@color/bg_e6eaf3" />
<!-- 모서리 곡선 설정 -->
<corners
android:topLeftRadius="15dp"
android:topRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"/>
<!-- 선 크기 및 색 지정 -->
<stroke
android:width="0dp"
android:color="#FFFF" />
</shape>
결과물은 다음과 같습니다.
이 결과물을 background로 적용시켜보면 다음 처럼 활용할 수 있습니다.
먼저 코드
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/rrrr_bg"
android:gravity="center"
android:text="HELLO!"/>
더 자세한 설명은 아래 주소에 있습니다!
출처 - https://overoid.tistory.com/30
Android - Shape Drawable
안드로이드(Android)에는 Shape Drawable이라는 것이 있습니다. XML로 쉽게 Drawable 객체를 생성하는 것인데, 배경이미지를 만들 때 사용하면 편리합니다. 실제 비트맵을 사용하지 않아도 되므로 apk의 용
overoid.tistory.com
반응형