0

I have just started learning development on Android, and I am not able to view "Hellow World!" TextView in the Design Tab.

MainActivity.java:

package com.dummy.demoapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

activity_main.xml:

<?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="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" />

</android.support.constraint.ConstraintLayout>

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dummy.demoapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

The TextView appears in the Component Tree, but the preview of the activity is totally blank:

enter image description here

I tried zooming in, but the TextView is just not there.

[EDIT]: The red exclamation (!) gives me the following message:

enter image description here

And refreshing doesn't solve the problem. Any help?

  • Click that red exclaimation **(!)** mark in the top right corner. What error message do you see? – Michael Dodd Jul 13 '18 at 12:53
  • go for it : https://codelabs.developers.google.com/codelabs/constraint-layout/index.html – Sahdeep Singh Jul 13 '18 at 12:53
  • Can you post your `build.gradle` file? I suspect [this question](https://stackoverflow.com/questions/44449275/failed-to-load-appcompat-actionbar-with-unknown-error-in-android-studio) may be of interest. – Michael Dodd Jul 13 '18 at 12:58

4 Answers4

0

Android Studio sometimes does not appear upto you've success build, Build->Build&Run, then select your virtual device if there is a helloworld it's okay, it's not your code problem it's related with IDE.

Emre Tufekci
  • 147
  • 2
  • 11
0

I think it's you default AppTheme with color white , try to add color to TextView

android:textColor="@android:color/black"
wSakly
  • 387
  • 1
  • 10
0

Go to style.xml and change this:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

to

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
Vishal Sharma
  • 1,051
  • 2
  • 8
  • 15
0

Click on the blue icon at the top left corner and then click on force layout. and You will see the Hello World!

Nitin Jain
  • 1,314
  • 11
  • 15