【问题标题】:Fading android.support.v7.widget.Toolbar褪色 android.support.v7.widget.Toolbar
【发布时间】:2016-02-21 16:29:19
【问题描述】:

我想创建一个配置文件活动,它的工具栏应该看起来像这样:

到目前为止,我有这个:

另外我不明白如何摆脱这种阴影或叠加效果,也许这已经解决了我的问题。

activity_activity_profile.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.appmac.ron.app_newsfeed.ActivityProfil">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@drawable/toolbar_color"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_activity_profil" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

toolbar_color.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="90"
        android:centerColor="#7b7b7b"
        android:endColor="#2b2b2b"
        android:startColor="#ffffff"
        android:type="linear" />
</shape>

更新: 影子不见了,现在我想让我的工具栏透明,像这样:

我现在有这个:

如果需要更多代码,请告诉我,我会更新它。 感谢您的帮助!

【问题讨论】:

    标签: android android-toolbar user-profile


    【解决方案1】:

    在您的AppBarLayout 上将高度设置为0dp

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp"
        android:theme="@style/AppTheme.AppBarOverlay">
    

    您可能还想将背景移动到AppBarLayout

    【讨论】:

    • 非常感谢,帮了大忙!我更新了我的帖子,你也有一些建议吗? @Eugen Pechanec
    • 正如我所说,将背景从工具栏移动到 AppBarLayout。它应该是从#4000 到#0000 的渐变。将内容视图(滚动视图)放在 CoordinatorLayout 后面,并将 paddingTop 设置为?actionBarSize。不过,您最好发布另一个问题。
    • 我有这种褪色效果有帮助,但我想让它也透明,这样你就可以看到工具栏后面滚动的内容:/ @Eugen Pechanec
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-15
    • 2020-08-26
    • 1970-01-01
    • 1970-01-01
    • 2014-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多