android shape 의 사용 및 그 라 데 이 션,분할 선,테두리,반투명 그림자

5582 단어 androidshape쓰다
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
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기