简体   繁体   English

如何在Android中更改折叠工具栏的文本颜色和折叠工具栏的后退按钮颜色

[英]How to change the Text color of collapsing toolbar and the back button color of collapsing toolbar in android

Is there any library to achieve this effect below 下面是否有任何图书馆可以达到这种效果

  • There is pager in the Toolbar 工具栏中有寻呼机
  • This has to be a parallax effect of toolbar 这必须是工具栏的视差效果

在此处输入图片说明

The CollapsingToolBar that is in the Android Design lib will do what you are asking. Android Design库中的CollapsingToolBar可以完成您所要求的。

You will need to apply a custom toolbar theme. 您将需要应用自定义工具栏主题。 Here is an example (this IS your styles.xml file). 这是一个示例(这是您的styles.xml文件)。

<resources>

    <!-- Base application theme. -->
    <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>

    <style name="CustomToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <!-- HERE ARE THE CHANGES - Change color of different texts -->
        <item name="android:textColorPrimary">@color/wacky_blue</item>
        <item name="colorControlNormal">@color/toolbar_color</item>
    </style>


</resources>

then you will need to set this on your App Bar: 那么您需要在应用栏上进行设置:

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        ...
        android:theme="@style/CustomToolbarTheme"
        ...>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM