2014-11-26 13 views
10

Ich baue gerade eine App mit den neuen Material Design Guidelines. Ich benutze eine Toolbar und nicht eine Aktionsleiste.Wie ändere ich Text und Pfeilfarbe in Toolbar?

Ich möchte, dass der Text, das Überlaufsymbol und das Pfeil-/Hamburger-Symbol (etwas, das beim Ziehen der Navigationszeichnung umklappt) weiß statt schwarz sind, aber der Rest meines Themas muss die AppCompat sein. helles Thema.

Wenn jemand bitte erklären könnte, wie ich diese Dinge ändern würde, wäre ich sehr dankbar.

Ich muss auch die Farben sowohl in XML und über Java-Code ändern.

Und auf einer sub note, weiß jemand, wie ich einen Untertext in der Symbolleiste? Ich habe gelesen, dass es möglich ist, aber ich kann keine Ressourcen finden, wie es gemacht wird.

<LinearLayout 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimaryDark" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     /> 
    <com.bacon.corey.audiotimeshift.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/sliding_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="bottom" 
     sothree:panelHeight="0dp" 
     sothree:shadowHeight="10dp" 
     sothree:paralaxOffset="100dp" 
     sothree:fadeColor="@android:color/transparent" 

     > 

     <android.support.v4.widget.DrawerLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/drawer_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      > 
      <!-- The main content view --> 




       <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        xmlns:app="http://schemas.android.com/apk/res-auto" 
        android:padding="0dp" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        > 
        <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
         xmlns:app="http://schemas.android.com/apk/res-auto" 
         android:orientation="vertical" 
         android:padding="0dip" 
         android:gravity="center_horizontal" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_margin="0dp" 
         android:id="@+id/recordingListMainLayout" 
         android:foreground="@drawable/dim_shadow_shape_dark" 

         > 

         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
          xmlns:app="http://schemas.android.com/apk/res-auto" 
          android:orientation="vertical" 
          android:padding="0dp" 
          android:gravity="center_horizontal" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 

          > 

          <FrameLayout 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:id="@+id/mainLayoutContainer"/> 
       <!-- 
          <android.support.v4.view.ViewPager 
           android:id="@+id/viewPager" 
           android:layout_width="match_parent" 
           android:layout_height="0px" 
           android:layout_weight="1" 
           android:padding="0dp" 
           android:layout_margin="0dp" 
           /> 
       --> 


         </LinearLayout> 

        </FrameLayout> 
        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 
         <FrameLayout 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:background="@drawable/textview_rounded_corner_background_fam" 
          android:layout_alignParentRight="true" 
          android:layout_alignParentBottom="true" 
          android:layout_marginBottom="33dp" 
          android:layout_marginRight="90dp" 
          android:id="@+id/fabMainText" 

          > 
          <TextView 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Main Option - Quick Record" 
           android:textAlignment="center" 
           android:padding="6dp" 
           android:fontFamily="sans-serif-medium" 

           /> 
         </FrameLayout> 
         <com.bacon.corey.audiotimeshift.FloatingActionsMenu 
          android:id="@+id/fabMenu" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="bottom|right" 
          android:gravity="right" 
          app:fab_addButtonColorNormal="@color/holo_red_light" 
          app:fab_addButtonColorPressed="@color/c16" 
          app:fab_addButtonPlusIconColor="@color/white" 
          app:fab_expandDirection="up" 
          android:layout_marginTop="10dp" 
          android:layout_marginRight="10dp" 
          android:layout_marginBottom="10dp" 
          android:layout_marginEnd="10dp" 
          android:layout_alignParentRight="true" 
          android:layout_alignParentBottom="true" 

          > 
          <LinearLayout 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:orientation="horizontal" 
           android:gravity="center_vertical" 
           > 
           <FrameLayout 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/textview_rounded_corner_background_fam" 
            android:layout_marginRight="14dp" 
            > 
            <TextView 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Option Four" 
             android:textAlignment="center" 
             android:padding="6dp" 
             android:fontFamily="sans-serif-medium" 

             /> 
           </FrameLayout> 

           <com.bacon.corey.audiotimeshift.FloatingActionButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            app:fab_colorNormal="@color/c15" 
            app:fab_colorPressed="@color/c15" 
            app:fab_size="mini" 
            /> 
          </LinearLayout> 
          <LinearLayout 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:orientation="horizontal" 
           android:gravity="center_vertical" 
           > 
           <FrameLayout 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/textview_rounded_corner_background_fam" 
            android:layout_marginRight="14dp" 

            > 
            <TextView 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Option Three" 
             android:textAlignment="center" 
             android:padding="6dp" 
             android:fontFamily="sans-serif-medium" 
             /> 
           </FrameLayout> 

           <com.bacon.corey.audiotimeshift.FloatingActionButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            app:fab_colorNormal="@color/c8" 
            app:fab_colorPressed="@color/c8" 
            app:fab_size="mini" 
            /> 
          </LinearLayout> 
          <LinearLayout 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:orientation="horizontal" 
           android:gravity="center_vertical" 
           > 
           <FrameLayout 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/textview_rounded_corner_background_fam" 
            android:layout_marginRight="14dp" 

            > 
            <TextView 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Option Two" 
             android:textAlignment="center" 
             android:padding="6dp" 
             android:fontFamily="sans-serif-medium" 
             /> 
           </FrameLayout> 

           <com.bacon.corey.audiotimeshift.FloatingActionButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            app:fab_colorNormal="@color/a1" 
            app:fab_colorPressed="@color/a1" 
            app:fab_size="mini" 
            /> 
          </LinearLayout> 
          <LinearLayout 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:orientation="horizontal" 
           android:gravity="center_vertical" 
           > 
           <FrameLayout 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/textview_rounded_corner_background_fam" 
            android:layout_marginRight="14dp" 

            > 
            <TextView 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Option One" 
             android:textAlignment="center" 
             android:padding="6dp" 
             android:fontFamily="sans-serif-medium" 
             /> 
           </FrameLayout> 

           <com.bacon.corey.audiotimeshift.FloatingActionButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            app:fab_colorNormal="@color/a2" 
            app:fab_colorPressed="@color/a2" 
            app:fab_size="mini" 
            /> 
          </LinearLayout> 
         </com.bacon.corey.audiotimeshift.FloatingActionsMenu> 
        </RelativeLayout> 
       </RelativeLayout> 
      <!-- The navigation drawer --> 
      <ListView android:id="@+id/left_drawer" 
       android:layout_width="240dp" 
       android:layout_height="match_parent" 
       android:layout_gravity="start" 
       android:choiceMode="singleChoice" 
       android:divider="@android:color/transparent" 
       android:dividerHeight="0dp" 
       android:background="#FFFFFF"/> 
     </android.support.v4.widget.DrawerLayout> 

     <!-- Sliding Panel Layout --> 
      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center|top" 
       android:textSize="16sp" 
       android:id="@+id/slideUpPanel" 
       > 

      </FrameLayout> 

    </com.bacon.corey.audiotimeshift.SlidingUpPanelLayout> 
</LinearLayout> 

Vielen Dank im Voraus für jede Hilfe.

Corey B :)

+0

' @ style/DrawerArrowStyle' und als nächstes auf Ihrer 'DrawerArrowStyle'' set @ android: Farbe/weiß ' –

Antwort

23

ist hier komplett Stil für Ihre Symbolleiste. Die Erklärung wird inline gegeben.

<style name="MyToolbar" parent="@style/ThemeOverlay.AppCompat"> 
    <!-- Title text --> 
    <item name="android:textColorPrimary">@android:color/white</item> 

    <!-- Title color in AppCompat.Light --> 
    <item name="android:textColorPrimaryInverse">@android:color/white</item> 

    <!-- Menu text--> 
    <item name="actionMenuTextColor">@android:color/white</item> 
    <!-- Overflow --> 
    <item name="android:textColorSecondary">@android:color/white</item> 
    <!-- This will change drawer icon --> 
    <item name="drawerArrowStyle">@style/WhiteDrawerIconStyle</item> 
    <!-- background of the --> 
    <!-- <item name="android:background">@color/color_primary</item> --> 
</style> 


<style name="WhiteDrawerIconStyle" parent="Widget.AppCompat.DrawerArrowToggle"> 
    <item name="spinBars">true</item> 
    <item name="color">@android:color/white</item> 
</style> 

Auf Untertitel Hinweis: Sie können mToolbar.setSubtitle(sutitle);

+0

Das war perfekt , Vielen Dank! Corey :) – Fishingfon

2

In Ihrer App-Leiste verwenden, diese Eigenschaft hinzufügen.

App: theme = "@ style/Base.V7.Theme.AppCompat"

die Pflege aller Schlämmkreide nehmen sollte. Das referenzierte Thema besteht aus einer Symbolleiste mit weißen Elementen, sodass die Symbolleiste den Teil des Themas übernimmt, der für sie relevant ist.

Rufen Sie mToolbar.setSubtitle wie oben beschrieben auf.

+0

Thx, das war es für mich, nur dass es ein bisschen grau war. – Ivan

3

Setzen Sie app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" auf Ihre Toolbar xml. Und der Pfeil wird weiß.

<android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/toolbar_height" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
+0

Das war die Antwort, die dieses Weiß zu meinem Hamburger-Menü-Icon brachte, thx – Ivan

Verwandte Themen