Android Studio不显示layoutpreview

问题描述 投票:0回答:1

我正在尝试在Android Studio中创建布局,但布局的预览根本没有显示。但是没有错误。

我怎样才能让它正常工作?我将添加一个截图。

预览不加载布局

enter image description here

提前致谢。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.diceout.MainActivity"
tools:showIn="@layout/activity_main">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Let's Play!" />

<Button
    android:id="@+id/rollButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="155dp"
    android:layout_marginStart="155dp"
    android:layout_marginTop="25dp"
    android:text="Roll" />

</RelativeLayout>

的TextView

enter image description here

android android-studio
1个回答
0
投票

@ivan franken你能发布@ layout / activity_main Xml代码吗?我在你的content_main.xml上的代码中看到了这行tools:showIn:@layout/activity_main。我在我的项目中对它进行了测试,并得到了类似的结果。但是当我删除它时,它运行正常。

© www.soinside.com 2019 - 2024. All rights reserved.