Dipak
Dipak

Reputation: 99

Android Studio is not showing Design Preview But Application is running

I have updated my android studio. In my layout preview my design is not showing it says

NOTE: One or more layouts are missing the layout_width and layout_height attributes, required in most layouts.

OR: Automatically add all missing attributes. There is no error in application. It's running well. I have uninstalled my android studio but same issue occurred. In all my projects occurs the same issue.

I have updated SDK as well.

Here is layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinate_layout_sheet"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar_series"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorPrimaryDark"
                local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            </android.support.v7.widget.Toolbar>

            <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
                </LinearLayout>
            </android.support.v4.widget.NestedScrollView>

        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone">

            <ProgressBar
                android:id="@+id/pb_product"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="visible" />

            <TextView
                android:id="@+id/tv_no_record"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center"
                android:text="No record Found"
                android:textSize="18sp"
                android:visibility="visible" />
        </RelativeLayout>

        <!-- <android.support.v4.widget.NestedScrollView
             android:id="@+id/bottom_sheet_registration"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:background="#EEEEEE"
             android:clipToPadding="true"
             android:visibility="gone"
             app:layout_behavior="android.support.design.widget.BottomSheetBehavior">


             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginBottom="14dp"
                 android:orientation="vertical">

                 <include layout="@layout/bottomsheet" />
             </LinearLayout>
         </android.support.v4.widget.NestedScrollView>-->

        <View
            android:layout_width="match_parent"
            android:layout_height="60dp" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true">

            <Button
                android:id="@+id/btn_add_tocart"
                style="@style/Base.Widget.AppCompat.Button.Colored"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_weight="1"
                android:backgroundTint="#863029"
                android:text="Add To Cart"
                android:textAllCaps="false" />

        </RelativeLayout>
    </RelativeLayout>
</android.support.design.widget.CoordinatorLayout>

Upvotes: 0

Views: 985

Answers (2)

Pochmurnik
Pochmurnik

Reputation: 828

One of the possibility is that your Theme changes. Try changing it to Material -> Dark in the Preview view.

Link to the similar topic:

android studio preview not displaying? version 1.5.1

Upvotes: 0

MD. Shakif Ferdous
MD. Shakif Ferdous

Reputation: 76

This happens to me sometimes. What I do to fix this is to check styles.xml from res folder and check that the style AppTheme is correctly defined.

For example, if I want my app style to be without action bar, I use this as AppTheme:

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

... and add required items such as colorPrimary etc.

Then after rebuilding the gradle I usually can see my layout design again

Upvotes: 2

Related Questions