2017-03-27 11 views

答えて

4

あなたはこのようにそれを行うことができます:あなたはあなたのアプリケーション全体でこの機能を使用することができるとの境界線と背景色を置くことができ

public static void customView(View v, int backgroundColor, int borderColor) 
{ 
    GradientDrawable shape = new GradientDrawable(); 
    shape.setShape(GradientDrawable.RECTANGLE); 
    shape.setCornerRadii(new float[] { 8, 8, 8, 8, 0, 0, 0, 0 }); 
    shape.setColor(backgroundColor); 
    shape.setStroke(3, borderColor); 
    v.setBackgroundDrawable(shape); 
} 

あなたの選択。

+0

ShapeDrawableの使用はありませんか? – TeodorKolev

1

これを試してみてください。

 LayerDrawable bgDrawable = (LayerDrawable) btnCallnow.getBackground(); 
     final GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.shape_id); 
     shape.setCornerRadius(5.0f); 
+0

ShapeDrawableの使用はありませんか? – TeodorKolev

+0

Shape_idは、カスタム描画可能シェイプのIDです。 –

関連する問題