我正在关注很好的回购,它展示了如何使折叠工具栏WhatsApp-ProfileCollapsingToolbar 的自定义行为。
我不喜欢的是当工具栏下方的图片(工具栏的字体为白色)为白色时,工具栏不可见。所以我试图将工具栏的背景设置为某种颜色。
首先我添加到widget_header_view.xml android:background="@android:color/holo_red_light"
现在我有它:
<?xml version="1.0" encoding="utf-8"?>
<com.anton46.whatsapp_profile.HeaderView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_red_light"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="@dimen/header_view_start_text_size"
android:textStyle="bold" />
<TextView
android:id="@+id/last_seen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@android:color/white" />
</com.anton46.whatsapp_profile.HeaderView>
在activity_main.xml我已经app:contentScrim="?attr/colorPrimary"
改为app:contentScrim="@android:color/holo_red_light"
但是由于这个 repo 在WhatsappHeaderBehavior中使用边距,所以效果就像:
但我希望它是这样的:
编辑1:
https://stackoverflow.com/users/3436179/alexander在https://stackoverflow.com/a/372 80227/2401535 中提出的填充解决方案无济于事,因为“浮动”工具栏覆盖了后退按钮,如下所示: