gpt4 book ai didi

Android Studio 3.1.3 存在约束布局问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:05:59 26 4
gpt4 key购买 nike

我正在尝试在这里开始一个新项目,但出现了这个问题。我可以运行该项目并将其部署在模拟器中,但是这个渲染问题和使用私有(private)资源让我很不爽。我已经尝试了所有在互联网上找到的可能的解决方案,但还是无法解决问题

<?xml version="1.0" encoding="utf

<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!" />

</android.support.constraint.ConstraintLayout>

风格

<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" />

构建.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.acer.myapplication3"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:28.0.0-alpha3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'
}

最佳答案

有同样的问题 - 进入 SDK 管理器并安装了额外的 SDK 平台;奥利奥 8.1。问题似乎是"new"API 28 仍然存在问题。它说已部分安装,但我基本上只是选中了较低 API 的复选框并下载/安装了它:

screenshot of my API manager

此外,我更改了 build.gradle 文件的 SDK 版本、buildTools、appcompat 和设计版本,如下所示。它现在可以工作,我将在稍后解决这些问题后返回到 API 28。

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 27
...

dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.0.0'
}

关于Android Studio 3.1.3 存在约束布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50868924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com