0

I am a complete beginner,I just formatted some text in android studio but when I run the app on the emulator, nothing was shown. enter image description here

this is what the emulator shows

enter image description here

I have not done any coding yet, just add a text view, adjust its size, style, color and background.

from the event log I got this message

Emulator: Warning: Failed to get QCocoaScreen for NSObject(0x0) ((null):0, (null))

here is the code from activity_main.xml

<?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:id="@+id/textView2"
        android:layout_width="170dp"
        android:layout_height="41dp"
        android:layout_marginStart="174dp"
        android:layout_marginLeft="174dp"
        android:layout_marginTop="91dp"
        android:layout_marginEnd="178dp"
        android:layout_marginRight="178dp"
        android:layout_marginBottom="621dp"
        android:background="#FFC107"
        android:text="Hello World"
        android:textColor="#009688"
        android:textSize="30sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.486"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />
Kasım Özdemir
  • 5,414
  • 3
  • 18
  • 35
Tony
  • 39
  • 6
  • Add code for layout file and also add code how you are setting the text .. – ADM Apr 10 '20 at 03:57
  • May be you've set text in your layout using `tools:text="My grate app"` instead you should use `android:text = "my grate app"` – Parth Apr 10 '20 at 04:14
  • @Parth Hi Parth, I set everything by the attribute instead of code, sadly I just start the learning and have no idea how this code works – Tony Apr 10 '20 at 04:20
  • Do you mind editing your post and paste xml code here? – Parth Apr 10 '20 at 04:21
  • @Parth sure, is the activity_main.xml code? I don't know how to access that, every time I click it there is this graphical interface but no the code. – Tony Apr 10 '20 at 04:31
  • @Tony have a look at this. https://stackoverflow.com/questions/61094141/android-studio-3-6-1-layout-not-opening-in-an-editor-studio-not-showing-the-xm/61094159#61094159 – Parth Apr 10 '20 at 04:33
  • @Parth thanks got it, I would update xml text right away. – Tony Apr 10 '20 at 04:41

1 Answers1

1

Ahh, I see where the problem is. Your constraint is not right.

Just edit your textView like this.

<TextView
            android:id="@+id/textView2"
            android:layout_width="170dp"
            android:layout_height="41dp"
            android:background="#FFC107"
            android:text="Hello World"
            android:textColor="#009688"
            android:textSize="30sp"
            android:textStyle="bold"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

for more detail about constraint layout i would suggest you to read

constraint Layout

Parth
  • 791
  • 7
  • 17
  • Thank you so much and god bless you, and may i ask why those line of bias causes the problem? – Tony Apr 10 '20 at 05:06