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

时间:2022-03-02 01:00:12

I've been facing this problem for a few days now. Android studio is not able to render the DrawerLayout.

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

I found a few similar questions online but none of the solution worked for me.

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

I'm using Android Studio 1.2.1.1 with Gradle 1.2.3

我正在使用带有Gradle 1.2.3的Android Studio 1.2.1.1

I've tried changing the build tools to 22, 21, 19. Noting worked for me.

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

How can I make it work? If it's a bug, is there a workaround ?

我怎样才能使它工作?如果这是一个错误,是否有解决方法?

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

<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 个解决方案

#1


0  

Try to change your android version on your designer preview , which is render your xml.Android Studio-渲染问题:找不到抽屉布局

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

#1


0  

Try to change your android version on your designer preview , which is render your xml.Android Studio-渲染问题:找不到抽屉布局

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