Android Studio-渲染问题:找不到抽屉布局

时间:2015-06-02 12:32:55

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

我几天来一直在面对这个问题。 Android studio无法渲染DrawerLayout。

我在网上发现了一些类似的问题,但没有一个解决方案适合我。

我正在使用 Android Studio 1.2.1.1 Gradle 1.2.3

我已经尝试将构建工具更改为22,21,19。注意到我工作。

我怎样才能让它发挥作用?如果这是一个错误,是否有解决方法?

enter image description here enter image description here

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.MainScreenActivity">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/facebook_background">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:orientation="vertical">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/ic_empty_72" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center_horizontal"
                android:text="No Polls"
                android:textColor="@color/colorPrimary"
                android:textSize="14sp" />
        </LinearLayout>
    </RelativeLayout>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/polls_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/facebook_background">

        <ListView
            android:id="@+id/polls_listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:divider="@android:color/transparent"
            android:dividerHeight="10dp"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingTop="10dp"
            tools:listitem="@layout/item_poll" />

    </android.support.v4.widget.SwipeRefreshLayout>

    <com.gc.materialdesign.views.ProgressBarCircularIndeterminate
        android:id="@+id/fetchingDataProgressBar"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_gravity="center"
        android:background="@color/colorPrimary" />

    <com.getbase.floatingactionbutton.FloatingActionButton
        android:id="@+id/submitMain"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="16dp"
        app:fab_colorNormal="#1E88E5"
        app:fab_colorPressed="#0065BE"
        app:fab_icon="@drawable/ic_add_white_18dp" />

</FrameLayout>

<LinearLayout
    android:id="@+id/left_drawer"
    android:layout_width="280dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#1E272C"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/navigation_drawer_profileView"
        android:layout_width="match_parent"
        android:layout_height="150dp">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:src="@drawable/nav_drawer_background_orange" />

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/navigation_drawer_profileImage"
            android:layout_width="72dp"
            android:layout_height="72dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="16dp"
            android:src="@drawable/ic_profile_guy_blue"
            app:border_color="@color/white"
            app:border_width="2dp" />

        <TextView
            android:id="@+id/navigation_drawer_userName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/navigation_drawer_profileImage"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="5dp"
            android:text="UserName"
            android:textColor="@color/white"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/navigation_drawer_userLevel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/navigation_drawer_userName"
            android:layout_marginLeft="16dp"
            android:text="PickupNoob"
            android:textColor="@color/white"
            android:textSize="14sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="20dp"
            android:layout_marginTop="20dp"
            android:background="#55000000"
            android:padding="10dp"
            android:text="MY PROFILE"
            android:textColor="@color/white"
            android:textSize="16sp"
            android:textStyle="bold" />

    </RelativeLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/nav_item_login"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/nav_item_background"
                android:clickable="true"
                android:drawableLeft="@drawable/ic_nav_login"
                android:drawablePadding="20dp"
                android:gravity="center_vertical"
                android:padding="16dp"
                android:text="LOGIN / SIGNUP"
                android:textColor="@color/white"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/nav_item_about"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/nav_item_background"
                android:clickable="true"
                android:drawableLeft="@drawable/ic_nav_about"
                android:drawablePadding="20dp"
                android:gravity="center_vertical"
                android:padding="16dp"
                android:text="ABOUT"
                android:textColor="@color/white"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/nav_item_donate"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/nav_item_background"
                android:clickable="true"
                android:drawableLeft="@drawable/ic_nav_donate"
                android:drawablePadding="20dp"
                android:gravity="center_vertical"
                android:padding="16dp"
                android:text="DONATE"
                android:textColor="@color/white"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/nav_item_rate"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/nav_item_background"
                android:clickable="true"
                android:drawableLeft="@drawable/ic_nav_rate"
                android:drawablePadding="20dp"
                android:gravity="center_vertical"
                android:padding="16dp"
                android:text="RATE THE APP"
                android:textColor="@color/white"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/nav_item_feedback"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/nav_item_background"
                android:clickable="true"
                android:drawableLeft="@drawable/ic_nav_feedback"
                android:drawablePadding="20dp"
                android:gravity="center_vertical"
                android:padding="16dp"
                android:text="FEEDBACK"
                android:textColor="@color/white"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/nav_item_logout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/nav_item_background"
                android:clickable="true"
                android:drawableLeft="@drawable/ic_nav_logout"
                android:drawablePadding="20dp"
                android:gravity="center_vertical"
                android:padding="16dp"
                android:text="LOGOUT"
                android:textColor="@color/white"
                android:textSize="14sp" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

尝试在设计器预览中更改您的Android版本,这是渲染您的xml。enter image description here