2016-08-08 2 views
6

Ich bin auf der Suche nach der Rückseite Symbolbild auf der linken Seite der App-Leiste im Android, aber das Symbol in der Mitte der App (Werkzeug) bar angezeigt . Wie wird das Symbol auf der rechten Seite der App-Leiste in Android ausgerichtet? Bitte sehen Sie sich das Bild unten an.wie man Symbol auf der linken Seite der App-Leiste in Android

<menu 
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" 
tools:context="divine.calcify.activities.HomeScreenActivity"> 
    <item 
     android:layoutDirection="ltr" 
     android:id="@+id/hs_back_button" 
     android:icon="@mipmap/ic_back" 
     android:title="@string/homescreen_back" 
     app:showAsAction="always" 
     ></item> 
    <item 
     android:id="@+id/menu_search" 
     android:icon="@mipmap/ic_search" 
     android:title="@string/homescreen_search" 
     android:orderInCategory="1" 
     app:showAsAction="always" 
     app:actionViewClass="android.support.v7.widget.SearchView"/> 
    <item android:id="@+id/menu_notifications" 
     android:icon="@mipmap/ic_divine_notification" 
     android:title="@string/homescreen_notification" 
     android:orderInCategory="2" 
     app:showAsAction="always" /> 
</menu> 

enter image description here

+0

Verwenden Toolbar und stellen getSupportActionBar() setDisplayHomeAsUpEnabled (true); getSupportActionBar(). SetDisplayShowHomeEnabled (true); für Toolbar –

+0

willst du nur das Back-Symbol auf der linken Seite oder du willst beide Back-Icon und Hamburger-Icon zusammen? – himanshu1496

+0

@MujammilAhamed Ich habe versucht, was Sie vorgeschlagen, aber nicht funktioniert –

Antwort

1

Pragmatisch Taste in Java-Datei (in Activity)

dieses

ActionBar actionBar = getSupportActionBar(); 
actionBar.setDisplayHomeAsUpEnabled(true); 
actionBar.setTitle("Divine"); 
0

Sie müssen Toolbar statt ActionBar Probieren hinzufügen zurück. Toolbar gibt Ihnen die Freiheit, es als normale Ansicht frei zu gestalten.

Wenn Sie Toolbar noch nicht implementiert haben, kein Problem.

  1. Erweitern Sie Klasse ActionBarActivity
  2. Update-Thema mit Eltern Theme.AppCompat.Light.NoActionBar

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <!--<item name="colorPrimary">@color/colorPrimary</item>--> <!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>--> <!--<item name="colorAccent">@color/colorAccent</item>--> </style>

  3. Symbolleiste Layout erstellen. .

    <android.support.v7.widget.Toolbar 
        android:layout_width="match_parent" 
        android:layout_height="100dp" 
        android:minHeight="100dp" 
        android:background="@color/colorPrimary"> 
    
    
        <!--your views here--> 
    </android.support.v7.widget.Toolbar> 
    
  4. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);

Full Demo Here

Verwandte Themen