相关疑难解决方法(0)

是否可以使用除listview之外的其他内容作为drawerlayout中的滑动抽屉

我想有例如LinearLayout或者RelativeLayout从屏幕的,而不是一个孤独的左侧滑动ListView.

我试图将使用LinearLayoutandroid:layout_gravity="start"和我在运行时有此错误:

ClassCastException: android.widget.LinearLayout$LayoutParams cannot 
be cast to android.support.v4.widget.DrawerLayout$LayoutParams
Run Code Online (Sandbox Code Playgroud)

这是布局文件:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    >

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <LinearLayout 
        android:layout_width="320dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:orientation="vertical">

        <ImageView 
            android:id="@+id/ivwLogo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/video_icon"
        />

        <ListView 
            android:id="@+id/left_drawer"
            android:layout_width="320dp"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="@android:color/white"
        />

    </LinearLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢

android drawerlayout

34
推荐指数
3
解决办法
2万
查看次数

标签 统计

android ×1

drawerlayout ×1