TextView textView = (TextView) findViewById(R.id.textView); Resources res = textView.getResources(); int color = res.getColor(R.color.blue);
TextView textView = new TextView(this); Resources res = getResources(); int textSize = res.getDimensionPixelSize(R.dimen.font_size_large); textView.setTextSize(textSize);In this example, we create a new TextView and set its text size using the dimension value from the resources using the getDimensionPixelSize() method. Package library: android.content.res.Resources