例:
import android.graphics.drawable.GradientDrawable;
public class SomeDrawable extends GradientDrawable {
public SomeDrawable(int pStartColor, int pCenterColor, int pEndColor, int pStrokeWidth, int pStrokeColor, float cornerRadius) {
super(Orientation.BOTTOM_TOP,new int[]{pStartColor,pCenterColor,pEndColor});
setStroke(pStrokeWidth,pStrokeColor);
setShape(GradientDrawable.RECTANGLE);
setCornerRadius(cornerRadius);
}
}
用法:
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SomeDrawable vDrawable = new SomeDrawable(Color.BLACK,Color.GREEN,Color.LTGRAY,2,Color.RED,50);
View vView = new View(this);
vView.setBackgroundDrawable(vDrawable);
setContentView(vView);
}
}
结果:
最后
以上就是紧张溪流最近收集整理的关于Android动态实现shape,android – 动态创建一个Shape的全部内容,更多相关Android动态实现shape,android内容请搜索靠谱客的其他文章。
发表评论 取消回复