TextView setTextSize - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView setTextSize method.

This code example shows how to use the following methods: setPadding, setText, setTextColor, setTextSize
     
    TextView textView = (TextView)row.findViewById(android.R.id.text1);
    float scale = activity.getResources().getDisplayMetrics().density;
    boolean leftPadding = (parent.getTag().equals("right"));
    boolean topPadding = (position == 0);
    textView.setPadding((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(20 * scale) * (!leftPadding && topPadding ? 1 : 0), (int)(20 * scale), 0);
    textView.setText(item);
    textView.setTextColor(Color.BLACK);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
     
    return row;
  } 
 
  private View getWebView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    if ((row == null) || (row.findViewById(1337) == null)) {
      RelativeLayout layout = new RelativeLayout(activity);
      layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT));
      row = layout;
       
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setGravity, setPadding, setText, setTextSize
		playerText.setText(score.getPlayer());
		playerText.setGravity(Gravity.LEFT);
		playerText.setPadding(10, 10, 10, 10);
		playerText.setTextSize(16);
 
		TextView scoreText = new TextView(parent.getContext());
		scoreText.setText(String.valueOf(score.getScore()));
		scoreText.setGravity(Gravity.RIGHT);
		scoreText.setPadding(10, 10, 10, 10);
		scoreText.setTextSize(16);
 
		layout.addView(playerText);
		layout.addView(scoreText);
 
		return layout;
	} 
 
	public List<HighScore> getScores() {
		return scores;
	} 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getHeight, setGravity, setText, setTextColor, setTextSize
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setText, setTextColor, setTextSize
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        layout.addView(tscroll);
 
        // Now create the text view and add it to the scroller. 
        textView = new TextView(context);
        textView.setTextSize(16);
        textView.setTextColor(0xffffffff);
        textView.setText(textId);
        textView.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT));
        tscroll.addView(textView);
 
        // Add a layout to hold the buttons. 
        buttonHolder = new LinearLayout(context);
        buttonHolder.setBackgroundColor(0xf08080);
        buttonHolder.setOrientation(LinearLayout.HORIZONTAL);
        buttonHolder.setPadding(6, 3, 3, 3);
        layout.addView(buttonHolder, new LinearLayout.LayoutParams(
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setGravity, setMaxWidth, setMinWidth, setPadding, setText
	public void removeItemAt(int pos) {
		this.messages.remove(pos);
	} 
 
	public View getView(int pos, View convertView, ViewGroup parent) {
		TextView messageText = new TextView(parent.getContext());
		messageText.setText(this.getMessageText(pos));
		messageText.setGravity(Gravity.LEFT);
		messageText.setPadding(10, 10, 10, 10);
		messageText.setMaxWidth(200);
		messageText.setMinWidth(200);
		messageText.setTextSize(16);
 
		return messageText;
	} 
 
	private String extractMessageFromJsonObject(String json) {
		try { 
			ObjectMapper mapper = new ObjectMapper();
			Map<String, Object> jsonDic = mapper.readValue(json,
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setId, setLayoutParams, setGravity, setText, setTextColor
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		titleparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		titleparams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
 
		final TextView title = new TextView(getContext());
		title.setText(getTitle());
		title.setTextSize(24);
		title.setTextColor(Color.WHITE);
		title.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
		title.setGravity(Gravity.LEFT);
		title.setLayoutParams(titleparams);
		title.setId(TITLE_ID);
 
		layout.addView(title);
		layout.setOnClickListener(this);
		layout.setId(android.R.id.widget_frame);
 
		return layout;
		 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setText, setTextSize, setTypeface
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setSingleLine, setText, setTextColor, setTextSize
		LayoutParams textLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
		textLayoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
		textLayoutParams.setMargins(0, 0, 0, 0);
		textLayout.setLayoutParams(textLayoutParams);
 
		textView = new TextView(getContext());
		textView.setSingleLine(true);
		 
		LayoutParams textParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		textParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
		 
		if(this.text != null) {
			textView.setText(text);
		} 
	 
		if(textSize > 0) {
			textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
		} 
		else { 
			textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setGravity, setLines, setTextColor, setTextSize, setTypeface
    /** 
     * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. 
     * @param view the text view to be configured 
     */ 
    protected void configureTextView(TextView view) {
        view.setTextColor(textColor);
        view.setGravity(Gravity.CENTER);
        view.setTextSize(textSize);
        view.setLines(1);
        view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    } 
     
    /** 
     * Loads a text view from view 
     * @param view the text view or layout containing it 
     * @param textResource the text resource Id in layout 
     * @return the loaded text view 
     */ 
    private TextView getTextView(View view, int textResource) {
    	TextView text = null;
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, getText, length, setText, setTextColor
        lp.topMargin = 10;
        iv.setLayoutParams(lp);
         
         
        // Add label: 
        TextView tv = new TextView(this);
        lp = new LinearLayout.LayoutParams(
        		85, 
        		35); 
        lp.bottomMargin = 6;
        tv.setLayoutParams(lp);
         
        tv.setText(info.activityInfo.loadLabel(getPackageManager()));
        tv.setTextColor(Color.BLACK);
        tv.setTextSize(15);
         
        // First convert text to 'spannable' 
		tv.setText(tv.getText(), TextView.BufferType.SPANNABLE);
		Spannable str = (Spannable) tv.getText();
		 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related TextView setTextSize Questions & Answers:

setTextSize Method Overview
Set the default text size to the given value, interpreted as "scaled pixel" units.
See Code Examples for other Android TextView Methods: