김호쭈
DevForYou
김호쭈
전체 방문자
오늘
어제
  • 분류 전체보기 (321)
    • • 데이터베이스(DB) (9)
      • __SQL__ (9)
    • •알고리즘(Algorithm ) (117)
      • 문제풀이 (99)
      • 스터디 (14)
      • 알고리즘 팁 (4)
    • •Compter Science (57)
      • Operating System (25)
      • Computer Network (1)
      • Computer Vision (16)
      • Artificial Intelligence (14)
      • Software Technology (1)
    • • 독서 (36)
      • Design Pattern (24)
      • 객체지향의 사실과 오해 (1)
      • Object Oriented Software En.. (11)
    • • 개발 (26)
      • React (3)
      • node.js (6)
      • Django (11)
      • Spring boot (6)
    • • 개발Tip (4)
      • GitHub (0)
    • •프로젝트 (2)
      • 물물 (2)
    • •App (54)
      • 안드로이드 with Kotlin (50)
      • 코틀린(Kotiln) (4)
    • •회고 (8)
    • •취준일기 (3)
    • • 기타 (2)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • Remote저장소
  • GitHubDesktop
  • 로컬저장소
  • 원격저장소
  • 깃허브데스크탑
  • KMU_WINK
  • ㄱ
  • local저장소

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
김호쭈

DevForYou

[안드로이드] shape drawable, 쉐이프 드로어블으로 공모양 배경 만들기
카테고리 없음

[안드로이드] shape drawable, 쉐이프 드로어블으로 공모양 배경 만들기

2022. 3. 16. 02:15
 

'•App/안드로이드 with Kotlin' 카테고리의 글 목록

공부하고 정리하고 기록하기

devforyou.tistory.com

위 포스팅에서 소개한것과 같이, 로또번호 추첨기에서 썼던 것을 기반으로하여 drawble에대해서 정리해보려고한다. 


# ShapeDrawable

drawalbe에는 많은 종류가 있지만 해당 프로젝트를 하면서 shape를 이용해 원형모형의 색있는공을 만들었다.

 저 코드를 그대로 해석해보면 이런 파란색 원이 나온다. 그리고 색상을 수정하여 아래와 같이 배경이미지를 만들고, background속성으로 주면 적용 된다.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="oval"
  >
  <solid android:color="#0E5DE4"/>
  <size
    android:height="44dp"
    android:width="44dp"/>
</shape>

 모든 만약 공별로 img파일(png)을 배경으로 주면 리소스면에서 꽤 손해를 보게 된다. 저렇게 xml로 표현 가능한 경우에는 저런식으로 작성하게되면 용량면에서 이득을 볼 수 있다고 한다.

 

공식문서 예제.

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape=["rectangle" | "oval" | "line" | "ring"] >
    <corners
        android:radius="integer"
        android:topLeftRadius="integer"
        android:topRightRadius="integer"
        android:bottomLeftRadius="integer"
        android:bottomRightRadius="integer" />
    <gradient
        android:angle="integer"
        android:centerX="float"
        android:centerY="float"
        android:centerColor="integer"
        android:endColor="color"
        android:gradientRadius="integer"
        android:startColor="color"
        android:type=["linear" | "radial" | "sweep"]
        android:useLevel=["true" | "false"] />
    <padding
        android:left="integer"
        android:top="integer"
        android:right="integer"
        android:bottom="integer" />
    <size
        android:width="integer"
        android:height="integer" />
    <solid
        android:color="color" />
    <stroke
        android:width="integer"
        android:color="color"
        android:dashWidth="integer"
        android:dashGap="integer" />
</shape>

태그에 따른 꽤 많은 속성들이 존재하기 때문에 내가 필요할때마다 공식문서를 참고해가며 만들어 보도록 해야겠다.

 

 


 

공식문서참고.

 

드로어블 리소스  |  Android 개발자  |  Android Developers

드로어블 리소스 드로어블 리소스는 화면에 그릴 수 있으며 getDrawable(int)와 같은 API를 사용하여 가져오거나 android:drawable 및 android:icon과 같은 특성을 사용하여 다른 XML 리소스에 적용할 수 있는

developer.android.com

 

저작자표시 (새창열림)
    김호쭈
    김호쭈
    공부하고 정리하고 기록하기

    티스토리툴바