【问题标题】:How to remove bottom border in android action bar? [duplicate]如何删除android操作栏中的底部边框? [复制]
【发布时间】:2018-04-04 06:50:45
【问题描述】:

我在论坛中找到了,如何删除 Android 操作栏中的边框底部,但没有方法 (setElevation(0) and <item name="android:windowContentOverlay">@null</item>) 与我的示例一起使用。

总是有边框。

谢谢。

已解决:

我做到了!!抱歉,我很困惑,因为我认为边框/阴影是 ActionBar 主题,但不,它是 Activity 主题。我在活动样式中添加了“@null”,谢谢大家的帮助。

【问题讨论】:

    标签: android android-actionbar


    【解决方案1】:

    您可以通过以下代码移除ActionBar 上的高程/阴影:

    通过 xml:

     <android.support.design.widget.AppBarLayout
                android:id="@+id/appBarLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:elevation="0dp">
                ...
    </android.support.design.widget.AppBarLayout>
    

    Java:

    要使用 java 代码删除高程,只使用下面一行...getSupportActionBar().setElevation(0);

    或者,

     getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
     getSupportActionBar().setElevation(0);
    

    【讨论】:

    • 不起作用... :-(
    【解决方案2】:
    <!-- Theme without ActionBar shadow (inherits main theme) -->
        <style name="MyNoActionBarShadowTheme" parent="MyAppTheme">
            <item name="windowContentOverlay">@null</item>
            <item name="android:windowContentOverlay">@null</item>
        </style>
    

    在styles.xml文件中使用这个样式

    【讨论】:

    • 对手已经提到 @null 不起作用。
    • 不起作用,因为用 @null 显示下一个错误:找不到与给定名称匹配的资源:attr 'windowContentOverlay'。
    • @JMR 在活动 setTheme(R.style.MyNoActionBarShadowTheme); 中以编程方式尝试这种给定的样式,将此行添加为 onCreate 方法的第一行
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    相关资源
    最近更新 更多