android shape 의 사용 및 그 라 데 이 션,분할 선,테두리,반투명 그림자
우선 shape 에서 흔히 볼 수 있 는 속성 을 간단하게 알 아 보 세 요.(상세 소개 참조 api 문서 )
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape=["rectangle" | "oval" | "line" | "ring"] > --- rectangle
<corners -- shape=“rectangle” ,
android:radius="integer" -- , , 1dp,
android:topLeftRadius="integer"
android:topRightRadius="integer"
android:bottomLeftRadius="integer"
android:bottomRightRadius="integer" />
<gradient --
android:angle="integer"
android:centerX="integer"
android:centerY="integer"
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 -- , imageview scaleType 。
android:width="integer"
android:height="integer" />
<solid -- , 。( , OK)
android:color="color" />
<stroke -- ,border,dashWidth dashGap 0dp
android:width="integer"
android:color="color"
android:dashWidth="integer" --
android:dashGap="integer" /> --
</shape>
주의:1.android:radius,반경 은 아래 의 단일 각도 반경 속성 으로 덮어 집 니 다.기본 값 은 1dp 입 니 다.
2.사용 할 때 네 개의 각 도 를 따로 설정 하고 크기 가 일치 하지 않 으 면 eclipse 의 graphics preview 가 잘못 보 고 됩 니 다.하지만 직접 실제 기기 로 운행 하면 된다.예 를 들 어 실선 위의 직각,아래 의 굴절 효과)
Note: The shape scales to the size of the container View proportionate to the dimensions defined here, by default. When you use the shape in an
ImageView
, you can restrict scaling by setting the android:scaleType
to "center"
밤 을 들다1.그 라 데 이 션
res/drawable/gradient_box.xml
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFF0000"
android:endColor="#80FF00FF"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>
그림:2.흰색 테두리,반투명 효과
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="16dp" />
<!-- , , -->
<solid android:color="#80065e8d" />
<stroke
android:dashGap="0dp"
android:width="4dp"
android:color="@android:color/white" />
</shape>
그림:3.분할 효과:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:width="4dp"
android:color="@android:color/black" />
</shape>
그림:4.한쪽 구 부 림 효과
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"/>
<!-- , , -->
<solid android:color="#ff065e8d" />
<stroke
android:dashGap="0dp"
android:width="4dp"
android:color="@android:color/white" />
</shape>
그림:다른:색상 진 도 를 동봉 합 니 다.필요 한 것 은 찾 아 볼 수 있 습 니 다http://tools.jb51.net/static/colorpicker/index.html
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Kotlin의 기초 - 2부지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다. 유형 변환은 데이터 변수의 한 유형을 다른 데이터...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.