Remove ActionBar Border

↘锁芯ラ 提交于 2019-12-10 15:24:07

问题


So, here is the problem.

This border is showing up and I would like to remove it or at least change opacity. There was a shadow drop before because of Lollipop version, but I removed that with actionBar.setElevation(0);

Here is actionbar code from my class:

final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setElevation(0);
    actionBar.setCustomView(R.layout.appbar_layout);

Here is my style code:

<resources>

<style name="Theme.Example" parent="@style/Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/ActionBar.Solid.Example</item>
    <item name="android:toolbarStyle">@style/ToolbarStyle</item>
    <item name="toolbarStyle">@style/ToolbarStyle</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:actionModeBackground">@android:color/white</item>
</style>

<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
    <item name="contentInsetStart">0dp</item>
    <item name="android:contentInsetStart">0dp</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="ActionBar.Solid.Example" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="background">@android:color/white</item>
    <item name="android:titleTextStyle">@style/ActionBarStyle.Transparent.TitleTextStyle</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="ActionBarStyle.Transparent.TitleTextStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="android:background">@drawable/appbar_logo</item>
</style>


回答1:


In your app styles set the following:

 <style name="MyTheme" parent="@style/Theme.AppCompat.Light">
    <item name="colorPrimary">BORDER COLOR HERE</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
</style>

And in your manifest:

<application
    android:label="@string/app_name"
    android:theme="@style/MyTheme">
...
</application>



回答2:


More likely, if your api version >= 21, you need this:

AppBarLayout appBarLayout = findViewById(R.id.player_app_bar_layout);
appBarLayout.setOutlineProvider(null);


来源:https://stackoverflow.com/questions/33680251/remove-actionbar-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!