android studio中的渲染问题(android.support.v4.widget.DrawerLayout)

时间:2015-05-21 06:16:59

标签: android android-layout android-studio android-support-library

我尝试向我的应用添加滑动菜单,我在android studio xml预览中收到此消息:

  

渲染问题   找不到以下类:    - android.support.v4.widget.DrawerLayout(修复构建路径,创建类)
      提示:尝试构建项目。

这是我的xml代码:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- Put what you want as your normal screen in here, you can also choose for a linear layout or any other layout, whatever you prefer -->




</FrameLayout>



<!-- The navigation drawer -->
<RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"
    android:clickable="true">

    <ImageView
        android:id="@+id/imageView_bg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="centerCrop" />

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="250dp"
        android:layout_height="match_parent"

        >
        <LinearLayout
            android:id="@+id/drawerLinearLayout"
            android:orientation="vertical"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            >

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">


            </RelativeLayout>

    </LinearLayout>
</ScrollView>

</RelativeLayout>

这是gradle.build:

apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
flavorDimensions "api", "abi"
defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 17
    targetSdkVersion 20
    versionCode 2
    versionName "0.0.34"
  }
   buildTypes {
      release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
      }
    }
   productFlavors {
    }
   }

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// You must install or update the Google Repository through the SDK manager to use this dependency.
 compile 'com.google.android.gms:play-services:6.1.71'
 compile 'com.squareup.picasso:picasso:2.5.2'
 compile 'com.android.support:support-v4:20.0.0'
}

当我尝试构建并运行应用程序时s work fine but i can在android studio中看到预览。

我该如何解决这个问题?

0 个答案:

没有答案