sil*_*oid 2 android navigationview
我正在尝试将我自己的自定义标题视图添加到 Google 的新视图中,NavigationView但出于某种原因,无论我做什么,Android Studio 都会给我一个警告include,RelativeLayout这里不允许。我试着做
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<include layout="@layout/nav_drawer_header" />
<android.support.v7.widget.RecyclerView
android:id="@+id/nav_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cccc"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"/>
</android.support.design.widget.NavigationView>
Run Code Online (Sandbox Code Playgroud)
但只有RecyclerView出现,我不知道还能做什么。
我真的很感激一些帮助。谢谢!
您可以NavigationView使用app:headerLayoutXML 属性向 a 添加标题:
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_drawer_header" />
Run Code Online (Sandbox Code Playgroud)
或者通过inflateHeaderView() 以编程方式
| 归档时间: |
|
| 查看次数: |
1358 次 |
| 最近记录: |