Code example for ShapeDrawable

Methods: getPaint, setAlpha

0
     
    private void addButtonBorder(View button){
    	RectShape rect=new RectShape();
    	//TODO: round angles. Default "null" values don't work on android 2.2 
    	//RoundRectShape rect=new RoundRectShape(null,null,null); 
    	ShapeDrawable shape=new ShapeDrawable(rect);   	
    	Paint paint=shape.getPaint();
    	paint.setStrokeWidth(5);
    	paint.setStyle(Style.STROKE);
    	paint.setColor(Color.parseColor("#00FFFFFF"));
    	paint.setAlpha(255);
    	shape.setAlpha(255);    	
    	button.setBackgroundDrawable(shape);
    } 
 
	@Override 
	public void onClick(View v) {
		String id=(String) v.getTag();
		Log.d(TAG, "Clicked on button "+v.getId()+", tag="+id);
		 
		Intent i = new Intent(this, PlayQuizActivity.class);