Remove android.widget.Toolbar shadow

后端 未结 10 1277
庸人自扰
庸人自扰 2021-02-02 05:34

Using API21+ Toolbar:

// Toolbar
Toolbar toolbar = new Toolbar(this);
toolbar.showOverflowMenu();

Would like to remove its shadow

相关标签:
10条回答
  • 2021-02-02 06:06

    Put this code in Fragment in which you want to hide the ToolBar.

    @Override
    public void onResume() {
        super.onResume();
        ((AppCompatActivity)getActivity()).getSupportActionBar().setElevation(0);
    }
    
    0 讨论(0)
  • 2021-02-02 06:13

    If you are using AppBarLayout in toolbar, you can use: app:elevation="0dp" instead of android:elevation in AppBarLayout

    0 讨论(0)
  • 2021-02-02 06:14

    Use app:elevation="0dp" instead of android:elevation on your toolbar. If it is not work, put your toolbar inside of a AppBarLayout and set app:elevation="0dp":

    <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>
    
    0 讨论(0)
  • 2021-02-02 06:15

    set "#00000000" to the backgroundColor of toolbar , remember that: if you use CoordinatorLayout and AppBarLayout ,you should remove the app:layout_behavior="@string/appbar_scrolling_view_behavior" of your contentView , I have made this elementary mistake.

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