CoordinatorLayout在Android Studio 2.1.2中不起作用?

时间:2016-08-08 13:01:26

标签: android material-design android-coordinatorlayout android-studio-2.1

我的Android Studio无法找到CoordinatorLayout课程。

屏幕截图:

enter image description here

它说:

  

找不到以下类:-android.support.design.widget.CoordinatorLayout。

这是我的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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"
tools:context="com.musical_box.musicbox.MainActivity">


<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/player_Control_container">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>

我知道很多次都会问过这个问题但是我已经尝试了大部分解决方案,而且没有一个能为我工作。有一点我注意到Android Studio在编写代码时没有建议CoordinatorLayout。我猜测有一些缺少的库。这是我的gradle构建的代码:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.musical_box.musicbox"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
}

我在我的系统上安装了构建工具24.0.0。任何人都可以提供帮助,因为我无法弄清楚Android dev的问题和新功能。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

添加

CoordinatorLayout

到你的gradle文件。它应该工作。它是设计库的一部分。因此,您需要添加此项才能访问<template> <div class="grid__container games"> <h2>Games</h2> <div v-if="games"> <table> <tr> <th>Player One</th> <th>Results</th> <th>Player Two</th> <th>Played At</th> </tr> <tr v-for="game in games.data"> <td>{{ game.player_one }}</td> <td>{{ game.player_one_goals }} - {{ game.player_two_goals }}</td> <td>{{ game.player_two }}</td> <td>{{ [ game.created_at, "YYYY-MM-DD h:mm:ss" ] | moment "dddd, MMMMM, Do YYYYY" }}</td> </tr> </table> </div> </div> </template> <script> import auth from '../auth' export default { data() { return { data: '', games: '' } }, methods: { getGames() { this.$http .get('/api/games', { headers: auth.getAuthHeader() }).then((data) => { this.data = data this.games = JSON.parse(this.data.body) }, (error) => { console.log(error) }) } }, created: function () { this.getGames() } } </script>