Reputation: 213
I'm new to Android and I'm making an alarm clock for practice. I have my MainActivity
which shows a digital clock like this -
The add sign in the top right corner opens a new fragment to be able to set a new alarm but the problem is that the white digital clock text (shown in the first image) is peaking through into my fragment. I have tried to follow other suggestions that I've found on here such as setting the background to white on the fragment and also setting statelistanimator
to @null
but nothing has changed it. Here is the image(the overlap is on the text)-
Here is the XML for the fragment. (I have included only the parts that I believe are relevant, but i could be wrong).
<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"
android:background="@android:color/white"
android:clickable="true"
android:focusable="true"
tools:context=".SetAlarmFragment">
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:text="Choose a time"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
and here is the activity XML.
<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"
app:layout_constraintEnd_toEndOf="parent"
android:background="@color/colorPrimary"
tools:context=".MainActivity">
<FrameLayout
android:id="@+id/fragmentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<TextClock
android:id="@+id/textClock"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/digital"
android:textAlignment="center"
android:textColor="@color/design_default_color_background"
android:textSize="50sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/completeAlarmSetUp"
tools:text="12:30:01" />
Any help would be appreciated as well as any documentation that I can follow.
Thanks
Upvotes: 0
Views: 89
Reputation: 417
Try to move your <TextClock>
declaration in your activity.xml
above FrameLayout
. So Hierarchy will be [ConstraintLayout
{TextClock
, FrameLayout
}], You don't have to change constraints, just move FrameLayout
at the end.
Upvotes: 1