[英]Android Studio is not showing Design Preview But Application is running
I have updated my android studio. 我已经更新了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. 注意:一个或多个布局缺少大多数布局中所需的
layout_width
和layout_height
属性。
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.
我已经卸载了Android Studio,但发生了同样的问题。 In all my projects occurs the same issue.
在我所有的项目中都发生相同的问题。
I have updated SDK as well. 我也更新了SDK。
Here is layout.xml
这是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>
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.
我要解决的问题是从res文件夹中检查styles.xml并检查是否正确定义了样式AppTheme 。
For example, if I want my app style to be without action bar, I use this as AppTheme: 例如,如果我希望我的应用样式没有操作栏,则可以将其用作AppTheme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
... and add required items such as colorPrimary etc. ...并添加必填项,例如colorPrimary等。
Then after rebuilding the gradle I usually can see my layout design again 然后,在重新构建gradle之后,我通常可以再次看到我的布局设计
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? android studio预览不显示? version 1.5.1
版本1.5.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.