【问题标题】:I am Using Android Studio 3.1.3 and i got some errors我正在使用 Android Studio 3.1.3,我遇到了一些错误
【发布时间】:2018-08-11 06:03:24
【问题描述】:

在我的 android studio 3.1.3 中,它会显示以下错误

在当前主题中找不到样式“coordinatorLayoutStyle”

按钮

**This view is not constrained. It only has design-time positions, so it will jump to (0,0) at runtime unless you add the constraints.**

设计窗口总是显示空白

而且加载会花费很多时间

有什么建议吗...?

here is the image

content_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout 
    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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
   tools:showIn="@layout/activity_main">
   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
  </android.support.constraint.ConstraintLayout>

Style.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="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>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

【问题讨论】:

  • 你也可以发build.gradle文件吗?
  • 请向任何人发送 android studio 3.1.3 的 build.gradle 文件.....请

标签: android performance android-layout android-studio


【解决方案1】:

协调器布局和空白设计窗口的问题:这通常发生在您尝试使用 Android API 级别 28 编译项目时。转到您的 Gradle 文件(模块)并将 API 级别 28 更改为 27。此外,在该文件的缺点是,默认情况下可能有一些 API 版本为 28.x.xbeta 的条目。将其更改为 27.1.1 版本。同步并构建项目,你应该没问题。

某些视图不受约束:发生这种情况是因为您使用的是 ConstraintLayout,因此必须将视图约束到其他元素以保持其在屏幕上的位置。这很简单,因为您只需拖动边缘上的圆圈(在设计视图中),然后将箭头拖放到屏幕上的其他视图。您可以在以下位置查看更多信息:https://developer.android.com/training/constraint-layout/ 我建议您学习如何使用它,因为它是一个很好且有用的布局。

【讨论】:

  • 我试过了,但显示一些错误...无法解决:com.android.support:appcompat-v7:27.0.0-beta01 无法解决:com.android.support:design:27.0 .0-beta01
  • 将“27.0.0-beta01”更改为 27.1.1。 Android Studio 可能会显示一个错误,提示您尚未安装该构建版本,但它提供了安装它的选项。
【解决方案2】:

我在 Android Studion 3.1.3 中解决了这个渲染问题,只需在应用程序主题中添加这行。

<style name="AppTheme.NoActionBar">
  <item name="coordinatorLayoutStyle">@style/Widget.Design.CoordinatorLayout</item>
</style>

其实是android sdk 28 issue。

希望这会对您有所帮助...如果没有,请告诉我,我们可能还会找到其他解决方案。

【讨论】:

  • @Darshan 你添加了设计支持库吗?添加设计支持库,问题将得到解决
  • 请有其他建议
  • 在
  • @Darshan 你也可以使用设计支持版本 27。
  • 你在线..?
【解决方案3】:

请在build.gradle 文件中implementation 'com.android.support:appcompat-v7:27.1.1' 之后插入以下行代码

// here you can use your latest version which you have use in `com.android.support:appcompat-v7` instead of `27.1.1` 

implementation 'com.android.support:design:27.1.1'

【讨论】:

  • @Darshan,请参考SO Question
  • 我得到了这个错误..:在当前主题中找不到样式“coordinatorLayoutStyle”
猜你喜欢
  • 2021-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-05
  • 2020-01-03
  • 1970-01-01
  • 1970-01-01
  • 2015-02-02
相关资源
最近更新 更多