【问题标题】:How to change the Text color of collapsing toolbar and the back button color of collapsing toolbar in android如何在android中更改折叠工具栏的文本颜色和折叠工具栏的后退按钮颜色
【发布时间】:2018-12-26 13:51:38
【问题描述】:

下面有没有实现这个效果的库

  • 工具栏中有分页器
  • 这一定是工具栏的视差效果

【问题讨论】:

    标签: android


    【解决方案1】:

    Android 设计库中的 CollapsingToolBar 将满足您的要求。

    您需要应用自定义工具栏主题。这是一个示例(这是您的 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>
    

    那么您需要在应用栏上进行设置:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      • 2016-01-25
      • 1970-01-01
      • 2018-07-05
      相关资源
      最近更新 更多