Example usage for android.widget TextView getTextSize

List of usage examples for android.widget TextView getTextSize

Introduction

In this page you can find the example usage for android.widget TextView getTextSize.

Prototype

@ViewDebug.ExportedProperty(category = "text")
public float getTextSize() 

Source Link

Usage

From source file:com.tct.mail.browse.ConversationItemViewCoordinates.java

private ConversationItemViewCoordinates(final Context context, final Config config,
        final CoordinatesCache cache) {
    Utils.traceBeginSection("CIV coordinates constructor");
    final Resources res = context.getResources();
    mMinListWidthForWide = res.getDimensionPixelSize(R.dimen.list_min_width_is_wide);

    mMode = calculateMode(res, config);/* w  ww  . ja v  a  2s  .c  o  m*/

    final int layoutId = R.layout.conversation_item_view;

    ViewGroup view = (ViewGroup) cache.getView(layoutId);
    if (view == null) {
        view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null);
        cache.put(layoutId, view);
    }

    // Show/hide optional views before measure/layout call
    final TextView folders = (TextView) view.findViewById(R.id.folders);
    folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE);

    View contactImagesView = view.findViewById(R.id.contact_image);

    switch (config.getGadgetMode()) {
    case GADGET_CONTACT_PHOTO:
        contactImagesView.setVisibility(View.VISIBLE);
        break;
    case GADGET_CHECKBOX:
        contactImagesView.setVisibility(View.GONE);
        contactImagesView = null;
        break;
    default:
        contactImagesView.setVisibility(View.GONE);
        contactImagesView = null;
        break;
    }

    final View replyState = view.findViewById(R.id.reply_state);
    replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE);

    final View personalIndicator = view.findViewById(R.id.personal_indicator);
    personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE);

    setFramePadding(context, view, config.useFullPadding());

    // Layout the appropriate view.
    ViewCompat.setLayoutDirection(view, config.getLayoutDirection());
    final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY);
    final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

    view.measure(widthSpec, heightSpec);
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());

    // Once the view is measured, let's calculate the dynamic width variables.
    folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0);
    folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion)
            / 100.0);

    //        Utils.dumpViewTree((ViewGroup) view);

    // Records coordinates.

    // Contact images view
    if (contactImagesView != null) {
        contactImagesWidth = contactImagesView.getWidth();
        contactImagesHeight = contactImagesView.getHeight();
        contactImagesX = getX(contactImagesView);
        contactImagesY = getY(contactImagesView);
    } else {
        contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0;
    }

    final boolean isRtl = ViewUtils.isViewRtl(view);

    final View star = view.findViewById(R.id.star);
    final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start);
    starX = getX(star) + (isRtl ? 0 : starPadding);
    starY = getY(star);
    starWidth = star.getWidth();

    final TextView senders = (TextView) view.findViewById(R.id.senders);
    final int sendersTopAdjust = getLatinTopAdjustment(senders);
    sendersX = getX(senders);
    sendersY = getY(senders) + sendersTopAdjust;
    sendersWidth = senders.getWidth();
    sendersHeight = senders.getHeight();
    sendersLineCount = SINGLE_LINE;
    sendersFontSize = senders.getTextSize();

    final TextView subject = (TextView) view.findViewById(R.id.subject);
    final int subjectTopAdjust = getLatinTopAdjustment(subject);
    subjectX = getX(subject);
    subjectY = getY(subject) + subjectTopAdjust;
    subjectWidth = subject.getWidth();
    subjectHeight = subject.getHeight();
    subjectFontSize = subject.getTextSize();
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_S
    final TextView status = (TextView) view.findViewById(R.id.status);
    final int statusTopAdjust = getLatinTopAdjustment(status);
    statusX = getX(status);
    statusY = getY(status) + statusTopAdjust;
    statusWidth = status.getWidth();
    statusHeight = status.getHeight();
    statusFontSize = status.getTextSize();
    statusPaddingStart = ViewUtils.getPaddingStart(status);
    statusPanddingEnd = ViewUtils.getPaddingEnd(status);
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_E
    final TextView snippet = (TextView) view.findViewById(R.id.snippet);
    final int snippetTopAdjust = getLatinTopAdjustment(snippet);
    snippetX = getX(snippet);
    snippetY = getY(snippet) + snippetTopAdjust;
    maxSnippetWidth = snippet.getWidth();
    snippetHeight = snippet.getHeight();
    snippetFontSize = snippet.getTextSize();

    if (config.areFoldersVisible()) {
        // vertically align folders min left edge with subject
        foldersLeft = getX(folders);
        foldersRight = foldersLeft + folders.getWidth();
        foldersY = getY(folders) + sendersTopAdjust;
        foldersHeight = folders.getHeight();
        foldersTypeface = folders.getTypeface();
        foldersTextBottomPadding = res.getDimensionPixelSize(R.dimen.folders_text_bottom_padding);
        foldersFontSize = folders.getTextSize();
    } else {
        foldersLeft = 0;
        foldersRight = 0;
        foldersY = 0;
        foldersHeight = 0;
        foldersTypeface = null;
        foldersTextBottomPadding = 0;
        foldersFontSize = 0;
    }

    final View colorBlock = view.findViewById(R.id.color_block);
    if (config.isColorBlockVisible() && colorBlock != null) {
        colorBlockX = getX(colorBlock);
        colorBlockY = getY(colorBlock);
        colorBlockWidth = colorBlock.getWidth();
        colorBlockHeight = colorBlock.getHeight();
    } else {
        colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0;
    }

    if (config.isReplyStateVisible()) {
        replyStateX = getX(replyState);
        replyStateY = getY(replyState);
    } else {
        replyStateX = replyStateY = 0;
    }

    if (config.isPersonalIndicatorVisible()) {
        personalIndicatorX = getX(personalIndicator);
        personalIndicatorY = getY(personalIndicator);
    } else {
        personalIndicatorX = personalIndicatorY = 0;
    }

    final View infoIcon = view.findViewById(R.id.info_icon);
    infoIconX = getX(infoIcon);
    infoIconXRight = infoIconX + infoIcon.getWidth();
    infoIconY = getY(infoIcon);

    final TextView date = (TextView) view.findViewById(R.id.date);
    dateX = getX(date);
    dateXRight = dateX + date.getWidth();
    dateY = getY(date);
    datePaddingStart = ViewUtils.getPaddingStart(date);
    dateFontSize = date.getTextSize();
    dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline();

    final View paperclip = view.findViewById(R.id.paperclip);
    paperclipY = getY(paperclip);
    paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip);

    height = view.getHeight() + sendersTopAdjust;
    Utils.traceEndSection();
}

From source file:gr.scify.newsum.ui.ViewActivity.java

protected void updateTextSize() {
    final TextView tx = (TextView) findViewById(R.id.textView1);

    float defSize = tx.getTextSize();
    SharedPreferences usersize = ViewActivity.this.getSharedPreferences("textS", 0);
    float newSize = usersize.getFloat("size", defSize);
    tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, newSize);

}

From source file:gr.scify.newsum.ui.ViewActivity.java

private void initZoomControls() {
    final TextView tx = (TextView) findViewById(R.id.textView1);
    final float minm = tx.getTextSize();
    final float maxm = (minm + 24);

    // Add zoom controls
    ZoomControls zoom = (ZoomControls) findViewById(R.id.zoomControls1);
    zoom.setOnZoomInClickListener(new OnClickListener() {

        @Override// www  .j a v  a2s  . co  m
        public void onClick(View v) {
            if (tx.getTextSize() < maxm) {
                tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, tx.getTextSize() + 2);
                SharedPreferences textsize = getSharedPreferences("textS", 0);
                SharedPreferences.Editor editor = textsize.edit();
                editor.putFloat("size", tx.getTextSize());
                editor.commit();
            }
        }
    });
    zoom.setOnZoomOutClickListener(new OnClickListener() {// to the default
        // size

        @Override
        public void onClick(View v) {
            if (tx.getTextSize() > minm)
                tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, tx.getTextSize() - 2);
            SharedPreferences textsize = getSharedPreferences("textS", 0);
            SharedPreferences.Editor editor = textsize.edit();
            editor.putFloat("size", tx.getTextSize());
            editor.commit();
        }
    });

}

From source file:com.eurotong.orderhelperandroid.OrderMenuActivity.java

private View CreateMenuLine(VMMenulistOrder menu) {
    View menuRow = null;/* ww  w  .  j a  va  2s .  co m*/
    try {
        //menuRow = (View)getLayoutInflater().inflate(R.layout.order_menu_row, null);   
        menuRow = (View) getLayoutInflater().inflate(R.layout.order_menu_row_simple, null);

        TextView textViewMenuNr = (TextView) menuRow.findViewById(R.id.txtOrderMenuNr);
        if (textViewMenuNr != null) {
            textViewMenuNr.setText(menu.MenuNr);
        }
        TextView textViewOrderMenuName = (TextView) menuRow.findViewById(R.id.txtOrderMenuName);
        textViewOrderMenuName.setText(menu.MenuName);
        TextView textViewOrderCount = (TextView) menuRow.findViewById(R.id.txtOrderCount);
        textViewOrderCount.setText(Common.FormatDoubleToNoDecimal(menu.OrderCount));

        Button btnAddOne = (Button) menuRow.findViewById(R.id.btnAddOne);
        Button btnRemoveOne = (Button) menuRow.findViewById(R.id.btnRemoveOne);
        btnAddOne.setTag(menu);
        btnRemoveOne.setTag(menu);

        textCountSize = textViewOrderCount.getTextSize();

        SetStyleForOrderedMenu(menu, textViewOrderCount);

        btnAddOne.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AddOrder(v, 1);
            }
        });
        btnRemoveOne.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                AddOrder(v, -1);
            }
        });
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return menuRow;
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

@Override
public void onTextSizeChanged(final TextView textView, float oldSize) {
    if (mCurrentState != CalculatorState.INPUT) {
        // Only animate text changes that occur from user input.
        return;/*from  www .  j a va2 s . c o m*/
    }

    // Calculate the values needed to perform the scale and translation animations,
    // maintaining the same apparent baseline for the displayed text.
    final float textScale = oldSize / textView.getTextSize();
    final float translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd());
    final float translationY = (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f),
            ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f),
            ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f),
            ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.start();
}

From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java

ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, View fromView) {
    // Bookkeeping
    this.id = id;
    this.parentId = (parent != null) ? parent.getId() : null;

    // API 16+ properties
    this.scrollable = AT_16 ? fromView.isScrollContainer() : null;

    // API 11+ properties
    this.backgroundDrawableColor = (AT_11 && (fromView != null)
            && (fromView.getBackground() instanceof ColorDrawable))
                    ? ((ColorDrawable) fromView.getBackground()).getColor()
                    : null;/*from   w w  w. j av  a2 s.com*/

    // Base properties
    this.visibleToUser = ViewAccessibilityUtils.isVisibleToUser(fromView);
    this.className = fromView.getClass().getName();
    this.accessibilityClassName = null;
    this.packageName = fromView.getContext().getPackageName();
    this.resourceName = (fromView.getId() != View.NO_ID)
            ? ViewAccessibilityUtils.getResourceNameForView(fromView)
            : null;
    this.contentDescription = SpannableString.valueOf(fromView.getContentDescription());
    this.enabled = fromView.isEnabled();
    if (fromView instanceof TextView) {
        TextView textView = (TextView) fromView;
        // Hint text takes precedence if no text is present.
        CharSequence text = textView.getText();
        if (TextUtils.isEmpty(text)) {
            text = textView.getHint();
        }
        this.text = SpannableString.valueOf(text);
        this.textSize = textView.getTextSize();
        this.textColor = textView.getCurrentTextColor();
        this.typefaceStyle = (textView.getTypeface() != null) ? textView.getTypeface().getStyle() : null;
    } else {
        this.text = null;
        this.textSize = null;
        this.textColor = null;
        this.typefaceStyle = null;
    }

    this.importantForAccessibility = ViewAccessibilityUtils.isImportantForAccessibility(fromView);
    this.clickable = fromView.isClickable();
    this.longClickable = fromView.isLongClickable();
    this.focusable = fromView.isFocusable();
    this.editable = ViewAccessibilityUtils.isViewEditable(fromView);
    this.canScrollForward = (ViewCompat.canScrollVertically(fromView, 1)
            || ViewCompat.canScrollHorizontally(fromView, 1));
    this.canScrollBackward = (ViewCompat.canScrollVertically(fromView, -1)
            || ViewCompat.canScrollHorizontally(fromView, -1));
    this.checkable = (fromView instanceof Checkable);
    this.checked = (fromView instanceof Checkable) ? ((Checkable) fromView).isChecked() : null;
    this.hasTouchDelegate = (fromView.getTouchDelegate() != null);

    // There may be subtle differences between the bounds from a View instance compared to that of
    // its AccessibilityNodeInfo. The latter uses a @hide getBoundsOnScreen method, which clips to
    // parent bounds.
    android.graphics.Rect tempRect = new android.graphics.Rect();
    if (fromView.getGlobalVisibleRect(tempRect)) {
        this.boundsInScreen = new Rect(tempRect);
    } else {
        this.boundsInScreen = null;
    }
    this.nonclippedHeight = fromView.getHeight();
    this.nonclippedWidth = fromView.getWidth();
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java

/**
 * Applies the specified text appearance resource to a paint, returning the
 * text color if one is set in the text appearance.
 *
 * @param p     the paint to modify//from  w  ww.  j  a v a2 s .c  o m
 * @param resId the resource ID of the text appearance
 * @return the text color, if available
 */
private ColorStateList applyTextAppearance(Paint p, int resId) {
    // Workaround for inaccessible R.styleable.TextAppearance_*
    TextView tv = new TextView(mContext);
    if (SUtils.isApi_23_OrHigher()) {
        tv.setTextAppearance(resId);
    } else {
        //noinspection deprecation
        tv.setTextAppearance(mContext, resId);
    }

    p.setTypeface(tv.getTypeface());
    p.setTextSize(tv.getTextSize());

    final ColorStateList textColor = tv.getTextColors();

    if (textColor != null) {
        final int enabledColor = textColor.getColorForState(ENABLED_STATE_SET, 0);
        p.setColor(enabledColor);
    }

    return textColor;
}

From source file:com.google.corp.productivity.specialprojects.android.samples.fft.AnalyzeActivity.java

@SuppressWarnings("deprecation")
private void setTextViewFontSize() {
    TextView tv = (TextView) findViewById(R.id.textview_cur);
    // At this point tv.getWidth(), tv.getLineCount() will return 0

    Paint mTestPaint = new Paint();
    mTestPaint.setTextSize(tv.getTextSize());
    mTestPaint.setTypeface(Typeface.MONOSPACE);

    final String text = "Peak:XXXXX.XHz(AX#+XX) -XXX.XdB";
    Display display = getWindowManager().getDefaultDisplay();

    // pixels left
    float px = display.getWidth() - getResources().getDimension(R.dimen.textview_RMS_layout_width) - 5;

    float fs = tv.getTextSize(); // size in pixel
    while (mTestPaint.measureText(text) > px && fs > 5) {
        fs -= 0.5;//from  w  ww .jav a2  s  . c o m
        mTestPaint.setTextSize(fs);
    }
    ((TextView) findViewById(R.id.textview_cur)).setTextSize(fs / DPRatio);
    ((TextView) findViewById(R.id.textview_peak)).setTextSize(fs / DPRatio);
}

From source file:github.bewantbe.audio_analyzer_for_android.AnalyzeActivity.java

@SuppressWarnings("deprecation")
private void setTextViewFontSize() {
    TextView tv = (TextView) findViewById(R.id.textview_cur);
    // At this point tv.getWidth(), tv.getLineCount() will return 0

    Paint mTestPaint = new Paint();
    mTestPaint.setTextSize(tv.getTextSize());
    mTestPaint.setTypeface(Typeface.MONOSPACE);

    final String text = getString(R.string.textview_peak_text);
    Display display = getWindowManager().getDefaultDisplay();

    // pixels left
    float px = display.getWidth() - getResources().getDimension(R.dimen.textview_RMS_layout_width) - 5;

    float fs = tv.getTextSize(); // size in pixel
    while (mTestPaint.measureText(text) > px && fs > 5) {
        fs -= 0.5;//from  w w  w  . j a  v  a 2 s  .com
        mTestPaint.setTextSize(fs);
    }
    ((TextView) findViewById(R.id.textview_cur)).setTextSize(fs / DPRatio);
    ((TextView) findViewById(R.id.textview_peak)).setTextSize(fs / DPRatio);
}

From source file:org.de.jmg.learn.SettingsActivity.java

private void resize(float scale) {
    //if (scale == 0 && mScale!=1) return;
    Resources resources = _main.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    @SuppressWarnings("unused")
    int Density = metrics.densityDpi;
    try {//from  w ww.  j ava 2s  .  com
        int width = mainView.getWidth();
        if (width > 500) {
            width -= lib.dpToPx(40);
        } else {
            width -= lib.dpToPx(40);
        }
        if (scale == 0) {
            mainView.setVisibility(View.INVISIBLE);
            libLearn.gStatus = "Calculating Scale";

            float scale1 = width / (float) (_main.isSmallDevice ? 0
                    : (findViewById(R.id.txtCharsetASCII)).getWidth() + spnASCII.getWidth() + width / 30);
            float scale2 = width / (float) (_main.isSmallDevice ? 0
                    : (findViewById(R.id.txtSounds)).getWidth() + spnSounds.getWidth() + width / 30);
            float scale3 = width / (float) (_main.isSmallDevice ? 0
                    : (findViewById(R.id.txtCharsetASCII)).getWidth() + spnASCII.getWidth() + width / 30);
            scale = (scale1 < scale2) ? scale1 : scale2;
            scale = (scale3 < scale) ? scale3 : scale;
        }
        mScale = scale;

        ViewGroup Settings = (ViewGroup) findViewById(R.id.layoutSettings);
        libLearn.gStatus = "Enumerating ChildViews";
        int ChildCount = Settings.getChildCount();
        for (int i = 0; i < ChildCount; i++) {
            if (i > 100)
                break;
            libLearn.gStatus = "getting view " + i;
            View V = Settings.getChildAt(i);
            /*
            CharSequence cs = V.getContentDescription();
            if (cs != null && cs.length()>0 )
            {
               V.setOnLongClickListener(ViewOnLongClickCD);
            }
            */
            RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) V
                    .getLayoutParams();

            params.topMargin = (int) (params.topMargin * scale);
            params.bottomMargin = (int) (params.bottomMargin * scale);

            if (params.height > 0)
                params.height = (int) (params.height * scale);
            if (V instanceof CheckBox) {
                if (params.width > 0)
                    params.width = ((width - lib.dpToPx(10)) / 3);
            } else {
                if (params.width > 0)
                    params.width = (int) (params.width * scale);
            }
            /*
            if (V == spnSounds) {
               int soundsHeight = spnSounds.getHeight();
               float margin = (float) ((soundsHeight * scale) / 5.25);
               params.topMargin = params.topMargin + (int) margin;
            }
            */
            libLearn.gStatus = "Setting Layoutparams";
            V.setLayoutParams(params);
            // }
            if (V instanceof TextView && !(V instanceof CheckBox)) {
                libLearn.gStatus = "TextView set size";
                TextView t = (TextView) V;
                t.setTextSize(TypedValue.COMPLEX_UNIT_PX, t.getTextSize() * scale);
            } else if (V instanceof Spinner) {
                Spinner spn = (Spinner) V;
                SpinnerAdapter A = spn.getAdapter();
                if (A instanceof AbstractScaledArrayAdapter<?>) {
                    libLearn.gStatus = "Scaling Adapter";
                    AbstractScaledArrayAdapter<?> AA = (AbstractScaledArrayAdapter<?>) A;
                    AA.Scale = AA.Scale * scale;
                    if (spn.getSelectedItemPosition() > -1) {
                        AA.notifyDataSetChanged();
                    }

                }
            } else if (V instanceof CheckBox) {
                libLearn.gStatus = "CheckBox";
                CheckBox c = (CheckBox) V;
                //c.setScaleX(scale);
                //c.setScaleY(scale);
                // c.setle
                c.setTextSize(TypedValue.COMPLEX_UNIT_PX, c.getTextSize() * scale);

                /*
                int p1 = c.getPaddingTop();
                int p2 = c.getPaddingBottom();
                int p3 = c.getPaddingLeft();
                int p4 = c.getPaddingRight();
                c.setPadding((int) (p3/scale), p1, p4, p2);
                */
                //LevelListDrawable D = (LevelListDrawable) c.getBackground();
                /*
                Drawable d = c.getBackground();
                Log.d("bounds", d.getBounds().toString());
                */
                //d.setTargetDensity((int) (Density * scale));
                //d.setBounds(0, 0, c.getHeight(), c.getHeight());
                //lib.setBgCheckBox(c,d);
                /*
                ViewGroup check = (ViewGroup) V;
                for (int ii = 0; ii<check.getChildCount(); ii++)
                {
                   View cv = check.getChildAt(ii);
                   String cls = cv.getClass().getName();
                   Log.d("Classs", cls);
                }
                */
                // Drawable d = lib.getDefaultCheckBoxDrawable(_main);
                // d = new ScaleDrawable(d, 0, c.getHeight()*scale,
                // c.getHeight()*scale).getDrawable();
                // float scaleC = (float)c.getHeight()/d.getBounds().height();
                // d.setBounds(0, 0,(int) (c.getHeight()*scale),(int)
                // (c.getHeight()*scale));
                // LayerDrawable L = new LayerDrawable(new Drawable[]{d});
                // d = lib.scaleImage(_main, d, scaleC);
                // /c.setButtonDrawable(d);
            }
        }
        /*
        libLearn.gStatus="Buttons";
        Button b = (Button) findViewById(R.id.btnOK);
        RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) b
              .getLayoutParams();
        params.topMargin = (int) (params.topMargin * scale);
        if (params.height>0)params.height = (int) (params.height * scale);
        if (params.width>0)params.width = (int) (params.width * scale);
        b.setLayoutParams(params);
        b.setTextSize(TypedValue.COMPLEX_UNIT_PX, b.getTextSize() * scale);
                
        b = (Button) findViewById(R.id.btnCancel);
        params = (android.widget.RelativeLayout.LayoutParams) b
              .getLayoutParams();
        params.topMargin = (int) (params.topMargin * scale);
        if (params.height>0)params.height = (int) (params.height * scale);
        if (params.width>0)params.width = (int) (params.width * scale);
        b.setLayoutParams(params);
        b.setTextSize(TypedValue.COMPLEX_UNIT_PX, b.getTextSize() * scale);
        */
        SettingsView.getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

                    @Override
                    public void onGlobalLayout() {
                        // Ensure you call it only once :
                        lib.removeLayoutListener(SettingsView.getViewTreeObserver(), this);
                        int pos = spnASCII.getSelectedItemPosition();
                        spnASCII.setSelection(-1);
                        spnASCII.setSelection(pos);
                    }
                });

    } catch (Exception ex) {
        lib.ShowException(_main, ex);
    } finally {
        mainView.setVisibility(View.VISIBLE);
    }

}