I’m doing a small project on Android Studio, and I’ve put a picture as a dark blue background. I inserted white text on top of this dark blue figure, but the white color in the letters still doesn’t show. The Graphical Interface. See that I put the color white, but it still doesn’t show up. Please, check out:
Please, can anyone help to [1]: https://i.stack.imgur.com/iTtiS.png
Source-code in the XML: [2]: https://i.stack.imgur.com/u6AIU.png
Please, what to do to the white text appear on the top of the image in Android Studio?
Whole XML Layout:
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="410dp" android:layout_height="250dp" android:color="@color/white" android:foreground="@drawable/home_bg" android:textSize="30dp" android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Encontre o seu próximo destino!" android:textColor="@android:color/white" android:textSize="20dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.32" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.233" /> <TextView android:id="@+id/textView2" android:layout_width="176dp" android:layout_height="41dp" android:layout_marginBottom="64dp" android:text="Procurar Destinos" android:textColor="#FFFFFF" android:textColorHighlight="@color/white" android:textSize="20dp" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.324" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView" app:layout_constraintVertical_bias="0.742" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
Advertisement
Answer
Ok I think the problem is that you’ve set the foreground of the constraint layout instead of the background.
Try this:
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="410dp" android:layout_height="250dp" android:color="@color/white" android:background="@drawable/home_bg" android:textSize="30dp" android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent">