您的位置:首页 > 编程语言 > Java开发

在 java 中创建自己的 shapes +java实现边框

2016-04-15 15:45 495 查看
private void makeShapes() {

activeDrawable = new ShapeDrawable();
inactiveDrawable = new ShapeDrawable();
activeDrawable.setBounds(0, 0, (int) mIndicatorSize,
(int) mIndicatorSize);
inactiveDrawable.setBounds(0, 0, (int) mIndicatorSize,
(int) mIndicatorSize);

int i[] = new int[2];
i[0] = android.R.attr.textColorSecondary;
i[1] = android.R.attr.textColorSecondaryInverse;
TypedArray a = this.getTheme().obtainStyledAttributes(i);

Shape s1 = new OvalShape();
s1.resize(mIndicatorSize, mIndicatorSize);
Shape s2 = new OvalShape();
s2.resize(mIndicatorSize, mIndicatorSize);

((ShapeDrawable) activeDrawable).getPaint().setColor(
a.getColor(0, Color.DKGRAY));
((ShapeDrawable) inactiveDrawable).getPaint().setColor(
a.getColor(1, Color.LTGRAY));

((ShapeDrawable) activeDrawable).setShape(s1);
((ShapeDrawable) inactiveDrawable).setShape(s2);
}
GradientDrawable bgShape = new GradientDrawable();bgShape.setBounds(0, 0, tv.getWidth(), tv.getHeight());bgShape.setCornerRadius(10);bgShape.setStroke(2, base.UIColor.cBlue1);tv.setBackground(bgShape);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: