Q:

Resizing/Scaling Down Android Widgets (DatePicker and TimePicker)

I'm not sure if this is possible, and I couldn't find a topic based on it, but if it's been answered before drop me a link and that will be that.
What I'm looking to do right now is resize some of the default Android widgets, specifically DatePicker and TimePicker, to use in an Activity.  But as far as I can see the only result of modifying the width or height of either Picker (in a negative direction) results in a cropped view, rather than a scaled/stretched view of the widget.
I am open to my own custom widgets of my own, but I would really prefer to keep this project as simple and clean as possible, matching the Android OS UI as much as possible, so using the native DatePicker and TimePicker seems like a logical choice to me.  If anyone knows how to scale these widgets down rather than cropping them, I'd really appreciate it.
Thanks.

A:

It is a very bad hack, but it should work:
Create a new view extending LinearLayout, overwrite method getChildStaticTransformation and setStaticTransformationsEnabled explicit to true.
In the method getChildStaticTransformation you can manipulate the tranformation parameter to scale down all the content of your extended LinearLayout.
And then add the DatePicker or something else as a child of this view.
EG:
 public class ZoomView
    extends LinearLayout
{

private float sf = 1f;

public ZoomView(final Context context, final AttributeSet attrs)
{
    super(context, attrs);
    setStaticTransformationsEnabled(true);
}

public ZoomView(final Context context)
{
    super(context);
    setStaticTransformationsEnabled(true);
}

public void setScaling(final float sf)
{
    this.sf = sf;
}

@Override
protected boolean getChildStaticTransformation(final View child, final Transformation t)
{
    t.clear();
    t.setTransformationType(Transformation.TYPE_MATRIX);
    final Matrix m = t.getMatrix();
    m.setScale(this.sf, this.sf);
    return true;
}

}

