Android Design库中的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"
...>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句