TextView setTextColor - 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 setTextColor 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;
       
9
CodeRank
This code example shows how to use the following methods:getHeight, setGravity, setText, setTextColor, setTextSize
8
CodeRank
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(
8
CodeRank
This code example shows how to use the following methods:setText, setTextColor
                } 
 
                TextView headline = (TextView) view.findViewById(android.R.id.text1);
                TextView subText = (TextView) view.findViewById(android.R.id.text2);
                headline.setText(error.sourceId() + ":" + error.lineNumber());
                subText.setText(error.message());
                switch (error.messageLevel()) {
                    case ERROR:
                        subText.setTextColor(Color.RED);
                        break; 
                    case WARNING:
                        // Orange 
                        subText.setTextColor(Color.rgb(255,192,0));
                        break; 
                    case TIP:
                        subText.setTextColor(Color.BLUE);
                        break; 
                    default: 
                        subText.setTextColor(Color.LTGRAY);
                        break; 

8
CodeRank
This code example shows how to use the following methods:getBottom, getTop, layout, setTextColor
                leftMin = Math.min(0,
                        center - (nextViewWidth / 2) - mPaddingPush - viewWidth);
            } 
            int leftMax = center - (viewWidth / 2);
            int newLeft = map(positionOffset, 1, 0, leftMin, leftMax);
            view.layout(newLeft, view.getTop(), newLeft + viewWidth, view.getBottom());
            view.setTextColor(Color.rgb(
                    map(positionOffset, 1, 0, mInactiveTextColor.red, mActiveTextColor.red),
                    map(positionOffset, 1, 0, mInactiveTextColor.green, mActiveTextColor.green),
                    map(positionOffset, 1, 0, mInactiveTextColor.blue, mActiveTextColor.blue)));
        } 
 
        // Move the view at position + 1. This will be the label for the 
        // right of the two fragments that may be visible on screen 
        if ((position + 1) < getChildCount()) {
            TextView view = (TextView) getChildAt(position + 1);
            int viewWidth = view.getWidth();
            int prevViewWidth = getChildAt(position).getWidth();
            int leftMin = center - (viewWidth / 2);
            int leftMax = Math.max(width - viewWidth,
8
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams, setGravity, setText, setTextColor
This code example shows how to use the following methods:setLinkTextColor, setMovementMethod, setPadding, setText, setTextColor
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		 
		setTitle("Information");
		 
		TextView tv = new TextView(this);
		tv.setTextColor(0xffffffff);
		tv.setLinkTextColor(0xffa3b8fe);
		int p = AndroidUtils.dipToPixel(this, 10);
		tv.setPadding(p, p, p, p);
		tv.setText(Html.fromHtml(getIntent().getStringExtra("info")));
		tv.setMovementMethod(LinkMovementMethod.getInstance());
		 
		ScrollView sv = new ScrollView(this);
		sv.addView(tv);
		 
		setContentView(sv);
	} 
} 
8
CodeRank
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
This code example shows how to use the following methods:setText, setTextColor
    } 
 
    @UiThread 
    void updateUi(String message, int color) {
        setProgressBarIndeterminateVisibility(false);
        textView.setText(message);
        textView.setTextColor(color);
    } 
 
    @UiThread(delay=2000) 
    void showNotificationsDelayed() { 
        Notification notification = new Notification(R.drawable.icon, "Hello !", 0);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
        notification.setLatestEventInfo(getApplicationContext(), "My notification", "Hello World!", contentIntent);
        notificationManager.notify(1, notification);
    } 
 
    @LongClick 
    void startExtraActivity() { 
        Intent intent = new Intent(this, ActivityWithExtra_.class);
7
CodeRank
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

Related TextView setTextColor Questions & Answers:

setTextColor Method Overview
Sets the text color.
See Code Examples for other Android TextView Methods: