Android Build a Simple Android App Creating the Screen Layout Setting a Fullscreen Theme

Uzair Khan
Uzair Khan
3,640 Points

When i run the application on the emulator all of the fun text is written over each other

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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:paddingBottom="50dp" android:paddingLeft="50dp" android:paddingRight="50dp" android:paddingTop="50dp" android:background="#51b46d" tools:context="com.example.uzair1996.funapplication.FunActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Did you know!!"
    android:textColor="@color/colorPrimaryDark"
    android:textSize="18sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.457"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.143" />

<TextView
    android:id="@+id/factTextView"
    android:layout_width="359dp"
    android:layout_height="68dp"
    android:text="Ants stretch when they wake up in the morning."
    android:textColor="#ffffffff"
    android:textSize="24sp"
    tools:layout_editor_absoluteX="13dp"
    tools:layout_editor_absoluteY="221dp" />

<Button
    android:id="@+id/showFactButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#ffffffff"
    android:text="Show Another Fun Fact"
    android:textSize="18sp"
    tools:layout_editor_absoluteX="66dp"
    tools:layout_editor_absoluteY="457dp" />

</RelativeLayout>

1 Answer

Jason Wiram
seal-mask
.a{fill-rule:evenodd;}techdegree
Jason Wiram
Full Stack JavaScript Techdegree Student 41,827 Points

When using a RelativeLayout you'll want to use layout properties like the following:

android:layout_below="@+id/factTextView"

This will allow you to position elements relative you each other using their ids. Also, remember that anything prefixed with "tools:" will only have an effect while developing and not when you run your code/app.