Positionieren Sie Menüelemente links von der Actionbank in Wabe
-
24-10-2019 - |
Frage
Ich möchte einige Menüelemente links von der Actionbank von Honycomb positionieren, habe jedoch keine Dokumentation gefunden, die gezeigt wird, wie dies zu tun ist. Es sieht so aus, als ob es möglich sein sollte, da die Kontakt -App auf der unmittelbaren links in der Navigationsleiste gesucht hat. Irgendeine Idee, wie ich Menüelemente links einstellen kann?
Lösung
Die ActionBar bietet Unterstützung für ein benutzerdefiniertes Layout zwischen dem Anwendungssymbol und den regulären Aktionsleistensymbolen. Beispiel:
// Set the custom section of the ActionBar with Browse and Search.
ActionBar actionBar = getActionBar();
mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null);
actionBar.setCustomView(mActionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
Andere Tipps
Hier ist, was für mich wie ein Traum funktioniert: In der Aktivität habe ich Folgendes:
//hiding default app icon
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
//displaying custom ActionBar
View mActionBarView = getLayoutInflater().inflate(R.layout.my_action_bar, null);
actionBar.setCustomView(mActionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM)
my_action_bar.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/turquoise">
<ImageButton
android:id="@+id/btn_slide"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@null"
android:scaleType="centerInside"
android:src="@drawable/btn_slide"
android:paddingRight="50dp"
android:onClick="toggleMenu"
android:paddingTop="4dp"/>
</RelativeLayout>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow