Code example for TextView

Methods: setPaddingsetSingleLine, setFocusable, setFocusableInTouchMode, setId, setLayoutParams

0
     * @param toLeftOf Align the new textview to the right of the argument 
     * @return TextView The that represents the digit 
     */ 
    private TextView createTimerDigit(int id, int textSize, TextView toRigthOf) {
        // Create the TextView 
        TextView digit = new TextView(getContext());
        digit.setId(id);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        if (toRigthOf != null) {
            params.addRule(RelativeLayout.RIGHT_OF, toRigthOf.getId());
            params.addRule(RelativeLayout.ALIGN_BASELINE, toRigthOf.getId());
        } 
        digit.setLayoutParams(params);
        digit.setPadding(0, this.mPadding, 0, this.mPadding);
        digit.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        digit.setTextColor(this.mColor);
        digit.setFocusable(false);
        digit.setFocusableInTouchMode(false);
        digit.setSingleLine(true);
        addView(digit);
        return digit;
    } 
 
    /**