TextView textView = findViewById(R.id.text_view); textView.setBackground(new ColorDrawable(Color.BLUE));
final TextView textView = findViewById(R.id.text_view); final Drawable drawable = getResources().getDrawable(R.drawable.background_image); textView.setBackground(drawable);In this example, an image is used as the background of the `TextView`. The image is retrieved as a `Drawable` object from the resources using the `getResources()` method and then assigned as the background of the `TextView`. Package Library: `android.widget` is a part of the Android system package library.