2016-03-19 13 views
0

enter image description hereAndroid Aktionsleiste: Ändern der Farbe des Aktionsschaltflächen und Titel zum Zentrum

hier ist das Bild kann bitte jemand mir empfehlen, wie die Symbolfarbe zu ändern und das Eigentum an der Aktionsleiste zum Zentrum ...

+0

Verwenden Sie einfach "android.support.v7.widget.Toolbar" und passen Sie Ihre ActionBar so an. – shobhan

+0

http://StackOverflow.com/a/12388200/3790150 – saeed

+0

Möglicherweise müssen Sie hierfür ein benutzerdefiniertes Aktionsleisten-Layout erstellen, das Sie der Aktionsleiste als benutzerdefinierte Anzeige hinzufügen können. –

Antwort

0

Versuchen Sie Folgendes:
ändern Pading, wenn Sie möchten.

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 

    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?attr/colorPrimary" 
    android:minHeight="@dimen/abc_action_bar_default_height_material"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:weightSum="1" 
     > 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:src="@drawable/ic_edit" 

      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:text="ABC" 
      android:gravity="center" 
      android:layout_weight="1" 
      android:textColor="@android:color/white" 

      /> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:paddingRight="10dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:src="@drawable/ic_edit"/> 
    </LinearLayout> 
</android.support.v7.widget.Toolbar> 

enter image description here

+0

Sorry funktioniert nicht –

+0

gibt es einen Fehler? –

+0

ja bitte schlagen Sie mir vor, wie man es hat ..... –

0

wie bereits.

Erstellen Sie in Ihrem Projekt das neue Layout custom_toolbar.xml.

Fügen Sie den folgenden Code in der obigen Datei hinzu.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 


    <ImageView 
     android:id="@+id/imgLeft" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_alignParentLeft="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="10dp" 
     android:src="@drawable/ic_events" /> 

    <ImageView 
     android:id="@+id/imgRight" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_alignParentRight="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginRight="10dp" 
     android:src="@drawable/ic_action" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="10dp" 
     android:text="Test" 
     android:textColor="@android:color/white" 
     android:textSize="25sp" /> 


</RelativeLayout> 

Und fügen Sie dann das Layout Ihrer Symbolleiste XML-Datei.

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/ColorPrimary" 
    android:elevation="4dp" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark"> 

    <include layout="@layout/custom_toolbar" /> 

</android.support.v7.widget.Toolbar> 

Hope this Ihnen helfen.