Example usage for android.widget TextView setTextSize

List of usage examples for android.widget TextView setTextSize

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setTextSize(float size) 

Source Link

Document

Set the default text size to the given value, interpreted as "scaled pixel" units.

Usage

From source file:Main.java

/**
 * Sets the font size for a {@link TextView}.
 *
 * @param textview   text view instance//  ww  w.jav  a 2  s.  com
 * @param size  font size in pixel
 */
public static void setFontSize(TextView textview, float size) {
    textview.setTextSize(size);
    textview.requestLayout();
}

From source file:Main.java

private static void addCount(Activity activity, Integer count, LinearLayout layout, String label) {
    if (count != null && count > 0) {
        TextView amt = new TextView(activity);
        amt.setTextSize(textSize);
        amt.setText(count.toString() + " " + label + "  ");
        layout.addView(amt);//from   w w  w  .  j a va 2  s  . c om
    }
}

From source file:Main.java

public static void addSpacer(Activity activity, LinearLayout layout, String sp, int size) {
    TextView mSpacer = new TextView(activity);
    mSpacer.setTextSize(size);
    mSpacer.setText(sp);/*  ww w.ja va  2 s  .c  o m*/
    layout.addView(mSpacer);

}

From source file:Main.java

private static void addText(Activity activity, String text, LinearLayout layout, int maxWidth) {
    TextView textView = new TextView(activity);
    textView.setTextSize(textSize);
    textView.setMaxWidth(maxWidth);// w  w w. j a  va 2 s  .com
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setText(text + "  ");
    layout.addView(textView);

}

From source file:Main.java

private static void setDialogFontSize(View view, int size) {
    if (view instanceof ViewGroup) {
        ViewGroup parent = (ViewGroup) view;
        int count = parent.getChildCount();
        for (int i = 0; i < count; i++) {
            setDialogFontSize(parent.getChildAt(i), size);
        }/* ww w . ja  v a  2 s  .  co m*/
    } else if (view instanceof TextView) {
        TextView textview = (TextView) view;
        textview.setTextSize(size);
    }
}

From source file:Main.java

public static TextView createTextView(Context context, String text) {
    TextView tv = new TextView(context);
    tv.setPadding(10, 10, 10, 10);//from  w w w .j a v  a 2  s.c om
    tv.setText(text);
    tv.setGravity(Gravity.CENTER);
    tv.setTextSize(24);
    tv.setTextColor(Color.RED);
    return tv;
}

From source file:cn.foxnickel.listentome.view.ViewUtil.java

public static View getWordsView(Context context, String word, @ColorRes int color, boolean isTextSelectable) {
    TextView tv = new TextView(context);
    tv.setTextColor(ContextCompat.getColor(context, color));
    tv.setPadding(0, 6, 0, 6);//  w  w  w .  jav  a  2 s  . c om
    tv.setTextSize(16);
    tv.setTextIsSelectable(isTextSelectable);
    tv.setGravity(Gravity.LEFT);
    tv.setText(word);
    return tv;
}

From source file:Main.java

public static void setTabWidgetTitle(Context context, TabWidget tabWidget, int size, int color) {
    TextView tv = null;
    for (int i = 0, count = tabWidget.getChildCount(); i < count; i++) {
        tv = ((TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title));
        tv.setTextSize(size);
        tv.getPaint().setFakeBoldText(false);
        tv.setTextColor(context.getResources().getColorStateList(color));
    }//from  w w w  .j a v a2s .  co  m
}

From source file:com.nagopy.android.xposed.utilities.ModBrightness.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@XMinSdkVersion(Build.VERSION_CODES.JELLY_BEAN_MR1)
@HandleInitPackageResources(targetPackage = XConst.PKG_SYSTEM_UI, summary = "??")
public static void brightnessDebugger(final String modulePath, final InitPackageResourcesParam resparam,
        final ModBrightnessSettingsGen settings) throws Throwable {
    if (!settings.brightnessDebugger) {
        return;/*from w  ww .j a  v a2s. c  o m*/
    }

    resparam.res.hookLayout(XConst.PKG_SYSTEM_UI, "layout", "super_status_bar", new XC_LayoutInflated() {
        @Override
        public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
            LinearLayout parent = (LinearLayout) liparam.view
                    .findViewById(liparam.res.getIdentifier("system_icon_area", "id", XConst.PKG_SYSTEM_UI));

            // ?
            TextView luxTextView = new TextView(parent.getContext());
            luxTextView.setTextSize(8);
            luxTextView.setSingleLine(false);
            luxTextView.setTextColor(Color.WHITE);
            luxTextView.setText("");
            parent.setGravity(Gravity.CENTER_VERTICAL);
            parent.addView(luxTextView, 0);
            AutoBrightnessController autoBrightnessChangedReceiver = new AutoBrightnessController(luxTextView);
            IntentFilter intentFilter = new IntentFilter(
                    AutoBrightnessController.ACTION_AUTO_BRIGHTNESS_CHANGED);
            intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
            parent.getContext().registerReceiver(autoBrightnessChangedReceiver, intentFilter);
        }
    });
}

From source file:Main.java

public static void showOkDialog(String title, String msg, Activity act) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(act);
    if (title != null) {

        TextView dialogTitle = new TextView(act);
        dialogTitle.setText(title);/*from w ww  .ja va 2 s  .c om*/
        dialogTitle.setPadding(10, 10, 10, 10);
        dialogTitle.setGravity(Gravity.CENTER);
        dialogTitle.setTextColor(Color.WHITE);
        dialogTitle.setTextSize(20);
        dialog.setCustomTitle(dialogTitle);

    }
    if (msg != null) {
        dialog.setMessage(msg);
    }
    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            dialog.dismiss();
        }
    });
    AlertDialog dlg = dialog.show();
    TextView messageText = (TextView) dlg.findViewById(android.R.id.message);
    messageText.setGravity(Gravity.CENTER);

}