【发布时间】:2016-04-05 12:37:30
【问题描述】:
在我发布了这个问题之后,它没有提供足够的细节,现在我已经到了问题发生的地步。所以我已将我的问题编辑为下面的特定方式
已编辑
您好,我尝试了许多可能的解决方案,但预览布局没有给出渲染错误。
它给出了 coordinatorLayout 的错误。它实际上显示了协调器布局的预览,但是当我使用
包含另一个布局时它什么也不显示<include layout="@layout/content_main" />
进入协调器视图
我已尝试清理和构建项目,已尝试将应用样式更改为以下样式
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
我已将预览 api 从 22 更改为其他
但没有任何效果。
虽然它会预览其他布局,但它不会在包含的布局和 coordinatorlayout 中都这样做。当我评论包含标签行时,它会显示其中的内容。
那么我在用这个协调视图和包含的布局做什么??
不知道!!我有 android studio 1.5.1,我只创建了一个空白活动而不是空活动,然后它会自动创建这些布局。不知道为什么
这里是代码 内容布局
<?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: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.algtek.magnetotest.MainActivity"
tools:showIn="@layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
协调器布局
<?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:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.algtek.magnetotest.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
-
你的 Android Studio 版本是多少?
-
您是否安装了所有必要的 SDK?
-
感谢您的帮助@Coeus 版本是 1.5.1
-
感谢您的帮助@Sajib 我需要哪个sdk?我正在添加一些来自 SDK Manager 的屏幕截图
-
你能试试 File > Invalidate caches and restart 吗?
标签: android android-studio android-coordinatorlayout coordinator-layout