TextView myTextView = new TextView(context); myTextView.setText("Hello, world!");
TextView myTextView = new TextView(context); myTextView.setText("Hello, world!"); myTextView.setTextColor(Color.RED); myTextView.setTextSize(20); myTextView.setGravity(Gravity.CENTER);This example sets the text color to red, text size to 20px, and text alignment to center using various methods provided by the TextView class. Package Library: android.widget Overall, the android.widget.TextView class provides a convenient way to display text in an Android application. It supports various text formatting options and can be customized to fit different design requirements.