2011-11-23 2 views
2

코드에서 이것을 정의 할 수는 있지만 코드에서 이런 종류의 것을 정의 할 수 있습니까?안드로이드 코드로 도형을 만들 수 있습니까?

도형 ([ "rectangle"| "line"| "ring"])의 값은 코드 (사용자 입력)에 의존해야합니다.

코드로 수행 할 수 있습니까? 내가 어떻게 할 수 있니?

<?xml version="1.0" encoding="utf-8"?> 
<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="integer" 
     android:centerY="integer" 
     android:centerColor="integer" 
     android:endColor="color" 
     android:gradientRadius="integer" 
     android:startColor="color" 
     android:type=["linear" | "radial" | "sweep"] 
     android:usesLevel=["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> 
+0

다음을 참조하십시오. http://stackoverflow.com/questions/6205354/defining-drawable-shape-with-in-java-code – Lucian

답변

3

형상 묘화는 연관된 클래스는 코드에서 모양을 구성하는 데 사용할 수있는 ShapeDrawable 있습니다.