Reputation: 133
I am a beginner in android development. I have created a android project. But in the preview section, I am not able to see the components. But components are visible when i run the same app on emulator i am able to see the components. I am missing some setting here? XML is given below.
<?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>
Upvotes: 2
Views: 775
Reputation: 66
I've had have also this problem and solved it by only selecting another "Theme" cause the default theme appTheme doesn't show added items. If you i.e. select Transulcent, any item becomes visible ;-)
cheers Oliwan
Upvotes: 2
Reputation: 10910
This does seem to be a bug in Android Studio. When it showed up for me, I fixed it by making a trivial change in the app build.gradle
(change version code), do a gradle sync, then change back and sync again.
After that, the design view worked again.
Upvotes: 0
Reputation: 793
Maybe sound a weird answer, but self-tested this.
Change the XML file's (maybe activity_x.xml) layout's root tag android.support.constraint.ConstraintLayout
to LinearLayout
, then preview will start working again (as happened in my case). [If not, then perform force refresh (R)]
Then switch back to old one, I mean: Change the XML file's (maybe activity_x.xml) layout's root tag LinearLayout
to android.support.constraint.ConstraintLayout
. And force a refresh.
Upvotes: 0