【发布时间】:2013-05-24 15:30:39
【问题描述】:
例如,我希望从屏幕左侧滑动LinearLayout 或RelativeLayout,而不是单独的ListView。
我尝试将 à LinearLayout 与 android:layout_gravity="start" 一起使用,但在运行时出现此错误:
ClassCastException: android.widget.LinearLayout$LayoutParams cannot
be cast to android.support.v4.widget.DrawerLayout$LayoutParams
这是布局文件:
<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>
谢谢
【问题讨论】:
-
你是如何在代码中引用你的 DrawerLayout 的?你能不能把那个贴出来。
-
对于遇到
android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams问题的其他人:this question 直接回答。
标签: android drawerlayout