【问题标题】:Hiding elevation of AppBar隐藏 AppBar 的高度
【发布时间】:2018-07-28 18:06:07
【问题描述】:

我正在尝试模拟一个大型 AppBar,它正在为其添加一些额外的布局。

为此,我在 AppBar 正下方放置了一个布局,并为其分配了相同的颜色,但我得到了高程阴影,正如您在这张图片中看到的那样:

我尝试为我的布局配置 4dp 高度(我也尝试使用 8dp)以避免阴影,但它并没有消失。

我怎样才能让那个阴影去模拟一个大的 AppBar?

【问题讨论】:

    标签: android android-actionbar material-design android-toolbar


    【解决方案1】:

    试试这个:

    ActionBar actionBar = getSupportActionBar();
    actionBar.setElevation(0f);
    

    或者您可以制作自己的视图并将其用作此答案中的操作栏:

    https://stackoverflow.com/a/15519711/5343907

    【讨论】:

      【解决方案2】:

      在布局的 xml 文件中,如果您添加 AppBarLayout 标签,您可以定义高程并将其设置为 0dp

      <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          app:elevation="0dp"></android.support.design.widget.AppBarLayout>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-01-27
        • 1970-01-01
        • 2016-01-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-16
        • 1970-01-01
        相关资源
        最近更新 更多