skip to Main Content

All of my textviews’s backgrounds are transparent. This is not very good for readability if the textview will be on top of other items. How do I give my textviews a background, specifically one matching the Day/Night theme?

Example, "TextView" on top of "Time Updated…":
Overlapping

Example XML Code of a textview:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/search_result"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="@style/TextAppearance.AppCompat.Medium"
    android:theme="@style/Theme.AppName" />

If it helps to know, the textview will be in a Listview in a ConstraintLayout.

Any help would be great, if I left out details, please ask for them!

2

Answers


  1. They default to whatever theme you are using. If your text views are transparent then it has to do with the theme or appearance lines you are using. You can change the style to a different theme like your day and night. It does not have to match the rest of the app. However, it normally looks better if it does.

    Login or Signup to reply.
  2. @style/Theme.AppName if this is your appTheme than have you set ?

    <item name="android:windowBackground">@color/colorAppBg</item>
    

    If yes than you can use @color/colorAppBg as your texview Background color

    & don’t forget to define that color in both UI mode Day/Night

    values-night/colors.xml

    values/colors.xml

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search