I just Installed Android Studio and Created a Project in it but whenever i add a TextView in it is not showing anything Even the TextView
Already Created by the Android Studio Is not Showing
Activity.xml
code is
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="wrap_content"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="25dp">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="67dp"
tools:text="Hello World" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
tools:text="sdfsfsfsfs" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Hello World" />
</android.support.constraint.ConstraintLayout>
Any Help Would Be appreciated.
Probably a late answer, but as long as it helps someone.
You are using the property tools:text
for your last textview. The tools namespace is just for layout preview in android studio.
For the textview to display something in runtime, you must use the android namespace and android:text
property like so:
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World" />
Also, only the first textview is constrained. Try adding constraints to the remaining TVs.
And, in case your design window is not showing any text but a blank screen, you may have to change the Theme for Preview in the design window to match your app theme (Eg: Material theme, Light, AppTheme, etc.) The sixth button, which shows "Material Theme" right now
Try that for your constraint layout.
<android.support.constraint.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="wrap_content"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Hello World" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Hello World!"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
tools:text="sdfsfsfsfs" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Hello World"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp" />
</android.support.constraint.ConstraintLayout>
Also, id/textview
will not render anything when the app is run because there is no android:text
property. tools:text
is just for the layout editor.
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Hello World" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With