Mam szufladę nawigacyjną wykonaną za pomocą szufladyukład i adapter. Chcę dodać przycisk wylogowania u dołu bocznego menu. Przeszedłem SO, ale nie mogłem rozwiązać. Główny plik xml ma widok listy w układzie szuflady.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_gravity="center"
android:orientation="vertical">
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/buttonbackground"
android:text="PHOTOS"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textColor="@color/white" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/buttonbackground"
android:text="VIDEOS"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textColor="@color/white" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/buttonbackground"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:text="HISTORY"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"></LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/navList"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_above="@+id/logout"
android:layout_gravity="left|start"
android:background="#ffeeeeee"></ListView>
<Button
android:id="@+id/logout"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="LogOut" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
<android.support.v4.widget.DrawerLayout/>
A lista jest zawyżana w kodzie Java.
private void addDrawerItems() {
String items[]={"Home","Video","Camera","History","Version"};
mAdapter=new ArrayAdapter<>(this,R.layout.listview_drawer_item_row,items);
mDrawerList.setAdapter(mAdapter);
}
Jak dodać przycisk na dole menu?
Odpowiedzi:
0 dla odpowiedzi № 1Czy możesz to wypróbować, jest to obejście, ale mam nadzieję, że da ci jakiś pomysł, aby rozwiązać problem
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left|start">
<ListView
android:id="@+id/navList"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_above="@+id/logout"
android:layout_gravity="left|start"
android:background="#ffeeeeee"></ListView>
<Button
android:id="@+id/logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="LogOut" />
</RelativeLayout>
0 dla odpowiedzi nr 2
Zgodnie z moim doświadczeniem i wiedzą musiszdodaj przycisk wylogowania jako widok stopki widoku listy lub ustaw go na dole w widoku nawigacji. Nie możesz umieścić przycisku poza nawigacją. Jeśli uda Ci się coś takiego osiągnąć, będziesz mógł przewijać tylko widok nawigacji, a nie przycisk wylogowania. Zakładam, że nie przewinie się on z nawigacją.
Aby to osiągnąć, utwórz niestandardowy układ zgodnie z wymaganiami i ustaw jako widok stopki lub ustaw go w dolnej części okna nawigacji.