2017-02-21 9 views
0

ShapeDrawable이 있습니다. 프로그래밍 방식으로 CornerRadius (TopLeftRadius & BottomLeftRadius)를 설정하고 싶습니다. 다음은 GradientDrawable의 TopLeftRadius 및 BottomLeftRadius를 프로그래밍 방식으로 설정하는 방법

내 XML입니다

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

<item android:top="5dp" 
    android:bottom="5dp"> 

    <shape android:shape="rectangle"> 
     <corners android:topLeftRadius="20dp" 
      android:bottomLeftRadius="20dp"/> 

     <solid android:color="#A2D368"/> 
    </shape> 
</item> 
</layer-list> 

답변

1

이 좋아합니까; 자세한 내용은

float mRadius=3f; 

    GradientDrawable drawable=new GradientDrawable(); 
    drawable.setShape(GradientDrawable.RECTANGLE); 
    drawable.setCornerRadii(new float[]{mRadius, mRadius, 0, 0, 0, 0, mRadius, mRadius}); 

click here

0
<shape android:shape="rectangle"> 
    <corners 
     android:topLeftRadius="@dimen/button_radius" 
     android:topRightRadius="0dp" 
     android:bottomLeftRadius="0dp" 
     android:bottomRightRadius="@dimen/button_radius"/> 
    <stroke 
     android:width="@dimen/button_stroke_width" 
     android:color="@color/colorBlack"/> 
    <gradient 
     android:angle="-90" 
     android:startColor="@color/colorLightPurple" 
     android:endColor="@color/colorDeepPurple" /> 
    </shape>