【问题标题】:Android ShapeDrawable set Background and Border programmaticallyAndroid ShapeDrawable 以编程方式设置背景和边框
【发布时间】:2015-09-15 05:24:35
【问题描述】:

我有一个ShapeDrawable

final ShapeDrawable drawable = new ShapeDrawable(shape);
drawable.getPaint().setStyle(Paint.Style.FILL);
drawable.getPaint().setColor(0xFFffffff);

我想为这个drawable设置边框(描边)颜色和宽度。

我试试setStyle(Paint.Style.FILL_AND_STROKE) 但它设置了相同颜色的背景和边框

【问题讨论】:

  • 你找到办法了吗?

标签: android drawable paint android-drawable


【解决方案1】:

使用

drawable.getPaint().setStyle(Paint.Style.STROKE);
drawable.getPaint().setStrokeWidth(2); // in pixel

【讨论】:

  • 那么缺少的边框颜色呢?这个答案不应该被投票,因为它没有回答主要问题。
猜你喜欢
  • 1970-01-01
  • 2017-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-25
  • 2011-01-09
  • 1970-01-01
相关资源
最近更新 更多