Java Code Examples for android.support.design.widget.AppBarLayout#setElevation()
The following examples show how to use
android.support.design.widget.AppBarLayout#setElevation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolbarActivity.java From SeeWeather with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAppBar = (AppBarLayout) findViewById(R.id.appbar_layout); mToolbar = (Toolbar) findViewById(R.id.toolbar); if (mToolbar == null || mAppBar == null) { throw new IllegalStateException( "The subclass of ToolbarActivity must contain a toolbar."); } mToolbar.setOnClickListener(v -> onToolbarClick()); setSupportActionBar(mToolbar); if (canBack()) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true); } if (Build.VERSION.SDK_INT >= 21) { mAppBar.setElevation(10.6f); } }
Example 2
Source File: ToolbarActivity.java From AndroidBleManager with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (provideContentViewId() != 0){ setContentView(provideContentViewId()); }else if (provideContentViewLayout() != null){ setContentView(provideContentViewLayout()); }else { throw new IllegalStateException("No main layout, you should set provideContentViewId or provideContentViewLayout"); } mAppBar = (AppBarLayout) findViewById(R.id.toolbar_layout); mToolbar = (Toolbar) findViewById(R.id.toolbar); if (mToolbar == null || mAppBar == null) { throw new IllegalStateException("No toolbar"); } setSupportActionBar(mToolbar); if (isCanBack()) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true); } //设置ToolBar下面的阴影 if (Build.VERSION.SDK_INT >= 21) { mAppBar.setElevation(0);//10.6f } }