how to remove shadow below actionbar with AppCompat.Light.NoActionBar?

后端 未结 10 1278
盖世英雄少女心
盖世英雄少女心 2020-12-03 00:35

I tried to remove the shadow below the toolbar with the Theme.AppCompat.Light.NoActionBar, using every recommendation of people who have ever answer it before, but no one wo

相关标签:
10条回答
  • 2020-12-03 01:12

    Just use after the super.onCreate(savedInstanceState);

    if(getSupportActionBar() != null)
    {
       getSupportActionBar().setElevation(0);
    }
    
    0 讨论(0)
  • 2020-12-03 01:13

    If your are not using Toolbar on the Layout and you have the default toolbar from AppCompactActivity this can help you

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
    getSupportActionBar().setElevation(0);
    

    At least it worked for me.

    Regards,

    0 讨论(0)
  • 2020-12-03 01:14

    @DmitryO Hum my xml is like this, i don't have android.support.design.widget.AppBarLayout, just the toolbar widget,

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:fab="http://schemas.android.com/apk/res-auto"
        xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:theme="@style/AppThemeAccueil">
    
        <View xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="@dimen/statusBarHeight"
            android:background="@color/accueil_colorDark"
            android:elevation="@dimen/statusBarElevation"/>
    
        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:popupTheme="@style/AppThemeAccueilToolbar"
            android:theme="@style/AppThemeAccueilToolbar"
            android:id="@+id/toolbarAccueil"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            materialdesign:elevation="0dp"
            android:elevation="0dp"
            android:outlineProvider="background"
            android:layout_marginTop="@dimen/appBarTopMargin" >
    
        </android.support.v7.widget.Toolbar>
    </RelativeLayout>
    

    Have I to had this ? (I think this will not change the result)

    0 讨论(0)
  • 2020-12-03 01:17

    use app:elevation="0dp" instead of android:elevation

    0 讨论(0)
  • 2020-12-03 01:18

    I had the same problem. Applying app:elevation="0dp" on android.support.design.widget.AppBarLayout solves the issue

    0 讨论(0)
  • 2020-12-03 01:23

    Just put your AppBarLayout inside of a LinearLayout on a separated XML file, and then, include this XML to your main XML.

    0 讨论(0)
提交回复
热议问题