小编sga*_*ga4的帖子

无法在DrawerLayout中对ListView使用layout_gravity

我想在我的应用程序中添加导航抽屉.这是代码:

<DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.abcxyz.properprojectdb.MyDrawerActivity">

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

    <ListView
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:id="@+id/listView"
        android:entries="@array/planets"></ListView>
</DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

我无法为ListView添加属性android:layout_gravity.我不知道它为什么不能使用(intellisense工作得很好,但它不会显示layout_gravity)

我运行时我的应用程序崩溃,但如果我用LinearLayout替换DrawerLayout,应用程序不会崩溃.我猜这是因为我没有为Lis​​tView添加属性android:layout_gravity. 在此输入图像描述 这是一个快照,显示layout_gravity也没有出现在intellisense中

android listview android-appcompat layout-gravity navigation-drawer

2
推荐指数
1
解决办法
3460
查看次数