1. Are you ready for the Galaxy S20? Here is everything we know so far!

Android Studio TextView Not showing when running app

Discussion in 'Android Development' started by Ronald Scholten, Sep 15, 2020.

  1. Ronald Scholten

    Thread Starter

    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 (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.     android:orientation="vertical" android:layout_width="match_parent"
    4.     android:layout_height="match_parent">
    5.  
    6.     <TextView
    7.         android:id="@+id/textView"
    8.         android:layout_width="match_parent"
    9.         android:layout_height="wrap_content"
    10.         android:gravity="center_horizontal"
    11.         android:text="Menu"
    12.         android:textSize="50sp" />
    13.  
    14.     <EditText
    15.         android:id="@+id/editTextTextMultiLine"
    16.         android:layout_width="match_parent"
    17.         android:layout_height="wrap_content"
    18.         android:ems="10"
    19.         android:gravity="start|top"
    20.         android:inputType="textMultiLine"
    21.         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." />
    22. </LinearLayout>
    activity_main.xml
    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.     xmlns:app="http://schemas.android.com/apk/res-auto"
    4.     xmlns:tools="http://schemas.android.com/tools"
    5.     android:layout_width="match_parent"
    6.     android:layout_height="match_parent"
    7.     tools:context=".MainActivity">
    8.  
    9.     <TextView
    10.         android:layout_width="wrap_content"
    11.         android:layout_height="wrap_content"
    12.         android:text="Hello World!"
    13.         app:layout_constraintBottom_toBottomOf="parent"
    14.         app:layout_constraintLeft_toLeftOf="parent"
    15.         app:layout_constraintRight_toRightOf="parent"
    16.         app:layout_constraintTop_toTopOf="parent" />
    17.  
    18. </androidx.constraintlayout.widget.ConstraintLayout>
    I am using android studio 4.0.1

    Hope you can help me with this.
     


Loading...
Similar Threads - Android Studio TextView
  1. akmishra_99
    Replies:
    0
    Views:
    177
  2. SeanOConnor
    Replies:
    1
    Views:
    300
  3. Alvaro Vargas
    Replies:
    0
    Views:
    329
  4. RagingRetard
    Replies:
    0
    Views:
    233
  5. Danz47
    Replies:
    0
    Views:
    882
  6. Ruben u Williams
    Replies:
    1
    Views:
    240
  7. Nightpoison
    Replies:
    0
    Views:
    463
  8. VooDooChicken
    Replies:
    1
    Views:
    166
  9. Cinemato
    Replies:
    0
    Views:
    434
  10. Sean Meagher
    Replies:
    2
    Views:
    541

Share This Page

Loading...