我想在我的应用程序中添加导航抽屉.这是代码:
<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,应用程序不会崩溃.我猜这是因为我没有为ListView添加属性android:layout_gravity.
这是一个快照,显示layout_gravity也没有出现在intellisense中
android listview android-appcompat layout-gravity navigation-drawer