【发布时间】:2018-05-21 07:15:05
【问题描述】:
我正在使用 Android Studio 3.0 制作一个 Android 应用程序。
但我面临的问题是布局编辑器/预览器无法正常工作。它有时不显示任何内容,有时显示一个带有所有导航按钮的灰色框。
这些是截图
我使用的是buildToolsVersion '26.0.2',支持库版本是23.0.1
任何帮助都会非常有帮助。
编辑:这是我的 XML 布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"/>
<ImageView
android:id="@+id/logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:background="@drawable/logo" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
android:textSize="33dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="15dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
【问题讨论】:
-
如果项目尚未构建,预览可能为空或错误。但如果已经构建,那么快速修复就是重新构建或清理项目......
-
^ 试试上面的方法,如果还是不行就去
File > invalidate cache/restart -
@Xenolion 感谢您的回答。我尝试过重建、清理、使缓存无效和重新启动,但没有一个解决方案真正起作用。有什么想法吗?
-
@MohammedAlSafwan 也尝试过,但没有奏效。我可以尝试任何其他解决方案吗?
-
你的布局有视图吗???
标签: java android android-layout layout android-gradle-plugin