[英]how to add different layouts/items in navigation drawer?
I have been trying to add some other things (like an image view or a text view) in my navigation drawer. 我一直在尝试在导航抽屉中添加其他一些内容(例如图像视图或文本视图)。 My nav.
我的导航 drawer already has a list view, which is working fine, plz tell me how to add other things inside the drawer, just as in google+ nav.
抽屉已经有一个列表视图,可以正常工作,请告诉我如何在抽屉中添加其他内容,就像在Google+导航中一样。 drawer.
抽屉。 plz give code if possible.
请尽可能提供代码。 Tx in advance.
提前发送。
this is my xml for drawer layout 这是我的抽屉布局XML
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/list_background"
android:choiceMode="singleChoice"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" />
Try something like this. 尝试这样的事情。 By using multiple 'layouts' and 'android:weight' you can add whatever you like in the 'LinearLayout', and also have a 'ListView' like I.
通过使用多个“ layouts”和“ android:weight”,您可以在“ LinearLayout”中添加任意内容,还可以像我一样拥有一个“ ListView”。
<LinearLayout
android:id="@+id/fullRightLayout"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/list_background"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/topLayout"
android:layout_width="240dp"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Anders Andersson"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:visibility="visible" />
</LinearLayout>
<ListView
android:id="@+id/drawer_list_right"
android:layout_width="240dp"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/list_background"
android:choiceMode="singleChoice"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" >
</ListView>
将您的列表视图包装在一些linearlayout中,然后放置在所需的位置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.