我找不到任何有关如何正确设计标准的资源Navigation Drawer .我有以下 XML,并且正在寻找填充多个 ListView 、更改 ListView 中文本字体等的方法。
我正在尝试设计类似于以下一些设计。
除了引用 Design doc 之外,我还在寻找文档、指南、代码、示例或其他方向。 .我正在寻找更多关于如何正确适应这种新的 Android 设计模式的实际代码,而不仅仅是关于它们的外观的想法。
抽屉导航
<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">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#ffffff"/>
</android.support.v4.widget.DrawerLayout>
TextView
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="Loading Content ..."
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="#000000" />
最佳答案
您可以为抽屉使用任何 ViewGroup,例如 LinearLayout。它不限于 ListView 和 FrameLayout。因此,您可以像其他任何 Activity 布局一样设置 Drawer View 的样式。您应该记住的唯一一件事是 NavigationDrawer 只能有两个 child 。第一个是 Activity 的布局,第二个是 Drawer。随意为它们设置样式!
<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">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- YOUR DRAWER -->
<LinearLayout
android:id="@+id/drawer_view"
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="start">
<!-- Use any Views you like -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#ffffff"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
关于android - 如何正确设计/设计 Android 抽屉导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18201727/