【问题标题】:How to hide the shadow of toolbar in android?如何在android中隐藏工具栏的阴影?
【发布时间】:2015-12-27 06:46:06
【问题描述】:

我在我的 Android 应用程序 中创建了一个工具栏。现在我想要隐藏如下图所示的 shadow

这是我的代码 app_bar_home.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="zitat.entwicklers.org.HomeActivity">

<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="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

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

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

<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="@drawable/ic_menu_share" /></android.support.design.widget.CoordinatorLayout>

【问题讨论】:

    标签: android android-layout android-actionbar android-toolbar


    【解决方案1】:

    只需在AppBarLayout 中添加app:elevation="0dp"

    【讨论】:

    • 具体活动怎么做?
    【解决方案2】:

    添加 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getSupportActionBar().setElevation(0); 在您的活动中setContentView() 之后

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-10
      • 2018-01-03
      • 2023-04-01
      • 2019-12-27
      • 2017-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多