• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Studio TextView Not showing when running app

Good day to all.
I am reading a tutorial book on how to build android apps.
I am now on the section: Building a Menu with LinearLayout.
It told me to make a new project With the empty activity templet.
With the name main_menu Root element LinearLayout Source set Main.
Then i had to add to the main_menu.xml In design mode A TextView to the UI.
Now when i run the app in the instant it should already show me the title and the text menu under it.
But it only shows me the blue title and no text field.
I wend on with the book hoping it will be sol-ft.
I had to add Menu and 50sp and center horizontal to it.
Then i had to add a multi-line TextView to the UI.
Added text to it, And run the app again.
No menu ore text view.
I also had copy and paset the code from main_menu.xml to activity_main.xml in the hope that that would help.
main_menu.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="Menu"
        android:textSize="50sp" />

    <EditText
        android:id="@+id/editTextTextMultiLine"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:gravity="start|top"
        android:inputType="textMultiLine"
        android:text="Select a layout type to view an example. The onClick atribute of each button will call a method which executes setContentView to load the new layout." />
</LinearLayout>
activity_main.xml
Code:
<?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">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

I am using android studio 4.0.1

Hope you can help me with this.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones