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:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static void addImgLinkText(final Context context, ArrayList<View> views, final String url,
        LinearLayout.LayoutParams params) {
    final TextView textView = new TextView(context);
    textView.setTextColor(Color.BLUE);
    textView.setLayoutParams(params);/*from w w  w  .  j  av a 2s  .com*/
    textView.setText("View image");
    textView.setTextSize(getTextSize(context));
    textView.setPadding(3, 3, 3, 3);
    textView.setTag(url);
    textView.setClickable(true);
    setupOnLinkClick(context, url, textView);
    views.add(textView);
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static TextView getTextView(Context context, LinearLayout.LayoutParams params, StringBuffer buffer) {
    TextView textView = new TextView(context);
    textView.setTextColor(Color.BLACK);
    textView.setLayoutParams(params);/*from  ww  w .  j  ava  2 s .c om*/
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setTextSize(getTextSize(context));
    textView.setText(Html.fromHtml(buffer.toString()));
    return textView;
}

From source file:csic.ceab.movelab.beepath.Util.java

/**
 * Displays a brief message on the phone screen. Taken from Human Mobility
 * Project code written by Chang Y. Chung and Necati E. Ozgencil.
 * //  ww w .ja va 2s.c o  m
 * @param context
 *            Interface to application environment
 * @param msg
 *            The message to be displayed to the user
 */
public static void toast(Context context, String msg) {

    TextView tv = new TextView(context);
    tv.setText(msg);
    Drawable bknd = context.getResources().getDrawable(R.drawable.white_border);
    tv.setBackgroundDrawable(bknd);
    tv.setPadding(20, 20, 20, 20);
    tv.setTextSize(20);

    Toast t = new Toast(context);
    t.setDuration(Toast.LENGTH_LONG);
    t.setView(tv);
    t.show();
}

From source file:azou.note.Wordcloud.java

@Override
public void printstats() {
    refresh();//  www .j a  v  a2  s  .  c o  m

    int textviewID = 0x7f0a0007;
    int i = 0;
    for (Map.Entry e : indwords.entrySet()) {
        if (i++ > 100)
            break;
        TextView tv = (TextView) this.findViewById(textviewID);
        tv.setText((CharSequence) e.getKey());
        tv.setTextSize(10 * (Integer) e.getValue());
        ++textviewID;
    }
}

From source file:at.wada811.android.library.demos.app.TabFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.layout_page, container, false);
    TextView textView = (TextView) view.findViewById(R.id.text);
    textView.setText(getTag());//from w w  w . j  ava2s . co  m
    textView.setTextSize(
            Math.min(DisplayUtils.getWidth(getActivity()) / 16, DisplayUtils.getHeight(getActivity()) / 16));
    return view;
}

From source file:com.alibaba.akita.samples.TestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        mContent = savedInstanceState.getString(KEY_CONTENT);
    }//from w w w.  j a v  a 2s  .c o m

    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);

    LinearLayout layout = new LinearLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(text);

    return layout;
}

From source file:itvector.wineguide.ui.wines.MainActivity.java

@Override
public void onShowDescription(WineModel wineModels) {
    AlertDialog builder = new AlertDialog.Builder(this).setCancelable(true)
            .setTitle(R.string.dialog_title_description)
            .setMessage(StringUtils.capitalize(wineModels.getWine_type()))
            .setPositiveButton(R.string.button_ok, (dialog, id) -> dialog.dismiss()).create();
    builder.show();/*from ww w. j av  a 2  s  .c  o m*/

    TextView textView = (TextView) builder.findViewById(android.R.id.message);
    textView.setTextSize(getResources().getDimension(R.dimen.dialog_message_description));
}

From source file:com.endiansoftware.echo.remotewatch.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    /*//from  www  . j a  v a 2s.  c  om
       // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
        GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);
    */

    /*
    // ?    ?? .
    Intent popupIntent = new Intent(context, Popup.class)
        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    //  .
    context.startActivity(popupIntent);
            
    */

    LinearLayout layout = new LinearLayout(context);
    //layout.setBackgroundResource(R.color.LightOrange);

    TextView tv = new TextView(context);
    // set the TextView properties like color, size etc
    tv.setTextColor(Color.RED);
    tv.setTextSize(15);

    tv.setGravity(Gravity.CENTER_VERTICAL);

    // set the text you want to show in  Toast
    tv.setText("My Custom Toast at Bottom of Screen");

    layout.addView(tv);

    Toast toast = new Toast(context); //context is object of Context write "this" if you are an Activity
    // Set The layout as Toast View
    toast.setView(layout);

    // Position you toast here toast position is 50 dp from bottom you can give any integral value
    toast.setGravity(Gravity.BOTTOM, 0, 50);
    toast.show();
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedMessage.java

@Override
public View getBody(final AppCompatActivity activity, final Integer textColor, final Float textSize,
        final boolean showLinkButtons) {

    final LinearLayout subjectLayout = new LinearLayout(activity);
    subjectLayout.setOrientation(LinearLayout.VERTICAL);

    final TextView subjectText = new TextView(activity);
    subjectText.setText(StringEscapeUtils.unescapeHtml4(src.subject != null ? src.subject : "(no subject)"));
    subjectText.setTextColor(textColor);
    subjectText.setTextSize(textSize);
    subjectText.setTypeface(null, Typeface.BOLD);

    subjectLayout.addView(subjectText);//ww  w .j  a v  a 2 s  .  c  o  m
    subjectLayout.addView(body.buildView(activity, textColor, textSize, showLinkButtons));

    return subjectLayout;
}

From source file:com.pixellostudio.qqdroid.BaseQuote.java

/** Called when the activity is first created. */
@Override//from   w  w w  .j  a v  a  2s .  co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setActionBarContentView(R.layout.show);

    getActionBar().setTitle(title);

    getActionBar().addItem(getActionBar().newActionBarItem(NormalActionBarItem.class)
            .setDrawable(R.drawable.seemore).setContentDescription("List"), R.id.actionbar_seemore);

    view = (ListView) findViewById(R.id.ListView);

    view.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(0, 1, 0, R.string.sharequote);
        }
    });

    adapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1);
    adapter2 = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(BaseQuote.this);

            TextView txt = new TextView(this.getContext());
            txt.setTextSize(Float.parseFloat(pref.getString("policesize", "20")));
            txt.setText(Html.fromHtml(this.getItem(position)));

            if (pref.getString("design", "blackonwhite").equals("blackonwhite")) {
                txt.setTextColor(Color.BLACK);
                txt.setBackgroundColor(Color.WHITE);
                txt.setBackgroundDrawable(
                        this.getContext().getResources().getDrawable(R.drawable.quote_gradient_white));
            } else if (pref.getString("design", "blackonwhite").equals("whiteonblack")) {
                txt.setTextColor(Color.WHITE);
                txt.setBackgroundColor(Color.BLACK);
                txt.setBackgroundDrawable(
                        this.getContext().getResources().getDrawable(R.drawable.quote_gradient_black));
            }

            return txt;
        }

    };

    String[] liste = (String[]) getLastNonConfigurationInstance();

    if (liste != null && liste.length != 0) {
        for (int i = 0; i < liste.length; i++) {
            adapter.add(liste[i]);
            adapter2.add(liste[i]);
        }

        this.setTitle(name);
    } else {
        new LoadQuotes().execute();
    }

    view.setAdapter(adapter2);
}